Skip to content
Permalink
Browse files
Close the classloader if it's a closeable (java7+)
  • Loading branch information
dkulp committed Oct 22, 2014
1 parent 95eb1fd commit f942adb8dabd3f5cc05872afea1b8fe06589a471
Showing 1 changed file with 13 additions and 0 deletions.
@@ -19,6 +19,7 @@

package org.apache.cxf.maven_plugin;

import java.io.Closeable;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
@@ -134,11 +135,17 @@ public void addCatalog(File catalogFile) throws IOException {
Model model = loadModel(opt);
if (model == null) {
listener.message(xsdFile, "Failed to create model");
if (loader instanceof Closeable) {
((Closeable)loader).close();
}
return -1;
}
Outline outline = model.generateCode(opt, listener);
if (outline == null) {
listener.message(xsdFile, "Failed to generate code");
if (loader instanceof Closeable) {
((Closeable)loader).close();
}
return -1;
}

@@ -148,8 +155,14 @@ public void addCatalog(File catalogFile) throws IOException {
model.codeModel.build(cw);
} catch (IOException e) {
listener.error(e);
if (loader instanceof Closeable) {
((Closeable)loader).close();
}
return -1;
}
if (loader instanceof Closeable) {
((Closeable)loader).close();
}
return 0;
}

0 comments on commit f942adb

Please sign in to comment.