Skip to content

Commit 66c9d0f

Browse files
committed
Support local P2 repos
1 parent 256d9fe commit 66c9d0f

File tree

1 file changed

+8
-5
lines changed
  • osgi.dependency.processing/src/main/java/com/dbeaver/osgi/dependency/processing/util

1 file changed

+8
-5
lines changed

osgi.dependency.processing/src/main/java/com/dbeaver/osgi/dependency/processing/util/FileUtils.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import java.net.HttpURLConnection;
3131
import java.net.URI;
3232
import java.net.URISyntaxException;
33+
import java.net.URLConnection;
3334
import java.nio.file.*;
3435
import java.nio.file.attribute.BasicFileAttributes;
3536
import java.util.*;
@@ -264,13 +265,15 @@ public static Path tryToDownloadFile(@NotNull URI fileURI, @org.jkiss.code.Nulla
264265
}
265266

266267
public static boolean tryToLoadFile(@NotNull URI artifactsURI) throws IOException, URISyntaxException {
267-
HttpURLConnection httpURLConnection = (HttpURLConnection) artifactsURI.toURL().openConnection();
268-
boolean fileExist = httpURLConnection.getResponseCode() == HttpURLConnection.HTTP_OK;
269-
httpURLConnection.connect();
268+
URLConnection urlConnection = artifactsURI.toURL().openConnection();
269+
boolean fileExist = !(urlConnection instanceof HttpURLConnection httpCon) || httpCon.getResponseCode() == HttpURLConnection.HTTP_OK;
270+
urlConnection.connect();
270271
try {
271-
fileExist = fileExist & httpURLConnection.getURL().toURI().equals(artifactsURI);
272+
fileExist = fileExist & urlConnection.getURL().toURI().equals(artifactsURI);
272273
} finally {
273-
httpURLConnection.disconnect();
274+
if (urlConnection instanceof HttpURLConnection httpCon) {
275+
httpCon.disconnect();
276+
}
274277
}
275278
return fileExist;
276279
}

0 commit comments

Comments
 (0)