File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
aws-lambda-java-runtime-interface-client/src/test/java/com/amazonaws/services/lambda/runtime/api/client Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -109,6 +109,34 @@ void testLoadAllClassesWithMultipleEntries(@TempDir Path tempDir) throws IOExcep
109109 }
110110 }
111111
112+ @ Test
113+ void testLoadAllClassesWithBlocklistedClass (@ TempDir Path tempDir ) throws IOException {
114+ File jarFile = tempDir .resolve ("blocklist-test.jar" ).toFile ();
115+
116+ try (JarOutputStream jos = new JarOutputStream (new FileOutputStream (jarFile ))) {
117+ JarEntry blockedEntry = new JarEntry ("META-INF/versions/9/module-info.class" );
118+ jos .putNextEntry (blockedEntry );
119+ jos .write ("dummy content" .getBytes ());
120+ jos .closeEntry ();
121+
122+ JarEntry normalEntry = new JarEntry ("com/test/Normal.class" );
123+ jos .putNextEntry (normalEntry );
124+ jos .write ("dummy content" .getBytes ());
125+ jos .closeEntry ();
126+ }
127+
128+ String originalClasspath = System .getProperty ("java.class.path" );
129+ try {
130+ System .setProperty ("java.class.path" , jarFile .getAbsolutePath ());
131+ ClasspathLoader .main (new String []{});
132+ // The test passes if no exception is thrown and the blocklisted class is skipped
133+ } finally {
134+ if (originalClasspath != null ) {
135+ System .setProperty ("java.class.path" , originalClasspath );
136+ }
137+ }
138+ }
139+
112140 private File createSimpleJar (Path tempDir , String jarName , String className ) throws IOException {
113141 File jarFile = tempDir .resolve (jarName ).toFile ();
114142
You can’t perform that action at this time.
0 commit comments