jvz commented on code in PR #3884:
URL: https://github.com/apache/logging-log4j2/pull/3884#discussion_r2461431257


##########
log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/model/PluginRegistry.java:
##########
@@ -101,24 +103,44 @@ private void loadPlugins(final ClassLoader classLoader, 
final Namespaces namespa
 
     private Namespaces decodeCacheFiles(final ClassLoader classLoader) {
         final long startTime = System.nanoTime();
-        final PluginCache cache = new PluginCache();
+        final PluginIndex index = new PluginIndex();
         try {
             final Enumeration<URL> resources = 
classLoader.getResources(PLUGIN_CACHE_FILE);
             if (resources == null) {
                 LOGGER.info("Plugin preloads not available from class loader 
{}", classLoader);
             } else {
-                cache.loadCacheFiles(resources);
+                while (resources.hasMoreElements()) {
+                    final URL url = resources.nextElement();
+                    try (final DataInputStream in = new DataInputStream(new 
BufferedInputStream(url.openStream()))) {
+                        final int count = in.readInt();
+                        for (int i = 0; i < count; i++) {
+                            final var builder = 
PluginEntry.builder().setNamespace(in.readUTF());
+                            final int entries = in.readInt();
+                            for (int j = 0; j < entries; j++) {
+                                // Must always read all parts of the entry, 
even if not adding, so that the stream
+                                // progresses
+                                final var entry = builder.setKey(in.readUTF())
+                                        .setClassName(in.readUTF())
+                                        .setName(in.readUTF())
+                                        .setPrintable(in.readBoolean())
+                                        .setDeferChildren(in.readBoolean())
+                                        .get();
+                                index.add(entry);
+                            }
+                        }
+                    }
+                }

Review Comment:
   This is an example of the type of trivial change that would have been simple 
to directly apply to the main branch but are now unable to do so without the 
formality of a PR and peer review.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to