BUG-8123: fix URL naming mixup 12/56012/1
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 25 Apr 2017 17:17:33 +0000 (19:17 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Tue, 25 Apr 2017 17:19:02 +0000 (19:19 +0200)
As it turns out URL.getFile() does the wrong thing, leading to us
taking the whole path as the module name, resulting in wrong comparison.

Change the code to analyze URL.getPath(), stripping it down to the
last component.

Change-Id: Ica3e387caf2924712151f4da5939487872f8e98c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/repo/YangTextSchemaContextResolver.java

index ec4f65b9a321097123dfb5a9fc1ee5350956be15..2dd566bf17c7b8047b30f3a1f030bcbfdbd0f742 100644 (file)
@@ -163,7 +163,9 @@ public final class YangTextSchemaContextResolver implements AutoCloseable, Schem
             IOException, YangSyntaxErrorException {
         checkArgument(url != null, "Supplied URL must not be null");
 
-        final SourceIdentifier guessedId = guessSourceIdentifier(url.getFile());
+        final String path = url.getPath();
+        final String fileName = path.substring(path.lastIndexOf('/') + 1);
+        final SourceIdentifier guessedId = guessSourceIdentifier(fileName);
         return registerSource(new YangTextSchemaSource(guessedId) {
             @Override
             public InputStream openStream() throws IOException {