Instead of e.g. this: [ERROR] yang-to-sources: Unable to parse yang
files from
/home/vorburger/dev/ODL/git/netvirt/vpnservice/aclservice/impl/src/main/yang
java.util.zip.ZipException: invalid LOC header (bad signature) at
java.util.zip.ZipFile.read(Native Method)
it will now report the much more useful variation like this:
java.io.IOException: Exception when reading from:
/home/vorburger/.m2/repository/org/opendaylight/netvirt/neutronvpn-api/0.3.0-SNAPSHOT/neutronvpn-api-0.3.0-SNAPSHOT.jar::META-INF/yang/neutronvpn.yang
at (...)
Caused by: java.util.zip.ZipException: invalid LOC header (bad
signature)
similar to earlier https://git.opendaylight.org/gerrit/#/c/42193/
Change-Id: Ic5bcdc8597825cdc0506516618ec13ede6433bc7
Signed-off-by: Michael Vorburger <vorburger@redhat.com>
import com.google.common.io.ByteSource;
abstract class YangSourceFromDependency extends ByteSource {
+
+ /**
+ * Return a description for this dependency, to be used for error output when
+ * working with the dependency.
+ */
+ abstract String getDescription();
+
+ @Override
+ public final String toString() {
+ return getDescription();
+ }
+
}
return source.length();
}
+ @Override
+ String getDescription() {
+ return source.getAbsolutePath();
+ }
}
public InputStream openStream() throws IOException {
return file.getInputStream(entry);
}
-}
\ No newline at end of file
+
+ @Override
+ String getDescription() {
+ return file.getName() + "::" + entry.getName();
+ }
+}
try (InputStream dataStream = yangFromDependency.openStream()) {
String contents = IOUtils.toString(dataStream);
byContent.putIfAbsent(contents, yangFromDependency);
+ } catch (IOException e) {
+ throw new IOException("Exception when reading from: " + yangFromDependency.getDescription(), e);
}
}