Skip to content

Commit

Permalink
[BCEL-376] ClassPath.close() throws UnsupportedOperationException when
Browse files Browse the repository at this point in the history
created with system-classpath
  • Loading branch information
garydgregory committed Feb 7, 2025
1 parent 11c0418 commit 5cf9151
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/changes/changes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ The <action> type attribute can be add,update,fix,remove.
<!-- FIX -->
<action type="fix" dev="ggregory" due-to="Gary Gregory">Replace internal use of Locale.ENGLISH with Locale.ROOT.</action>
<action issue="BCEL-375" type="fix" dev="ggregory" due-to="J. Lewis Muir, Gary Gregory">Wrong permissions on bcel .jar file in binary .tar.gz distribution file.</action>
<action issue="BCEL-376" type="fix" dev="ggregory" due-to="Dominik Stadler, Gary Gregory">ClassPath.close() throws UnsupportedOperationException when created with system-classpath.</action>
<!-- ADD -->
<action type="update" dev="ggregory" due-to="Gary Gregory">Add Const.MAJOR_25.</action>
<action type="update" dev="ggregory" due-to="Gary Gregory">Add Const.MINOR_25.</action>
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/org/apache/bcel/util/ModularRuntimeImage.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,11 @@ public void close() throws IOException {
classLoader.close();
}
if (fileSystem != null) {
fileSystem.close();
try {
fileSystem.close();
} catch (final UnsupportedOperationException e) {
// do nothing
}
}
}

Expand Down
8 changes: 7 additions & 1 deletion src/test/java/org/apache/bcel/util/ClassPathTestCase.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
* specific language governing permissions and limitations
* under the License.
*/

package org.apache.bcel.util;

import static org.junit.jupiter.api.Assertions.assertNotNull;
Expand All @@ -29,6 +28,13 @@

public class ClassPathTestCase extends AbstractTestCase {

@Test
void testClose() throws IOException {
try (ClassPath cp = new ClassPath(ClassPath.getClassPath())) {
assertNotNull(cp);
}
}

@Test
public void testGetClassFile() throws IOException {
assertNotNull(ClassPath.SYSTEM_CLASS_PATH.getClassFile("java.lang.String"));
Expand Down

0 comments on commit 5cf9151

Please sign in to comment.