Toni Helenius 2 years ago
parent
commit
d59b449f69

+ 5 - 5
jme3-templates/src/com/jme3/gde/templates/utils/mavensearch/MavenApiVersionChecker.java

@@ -58,12 +58,12 @@ public class MavenApiVersionChecker implements MavenVersionChecker {
 
 
     private static final String API_URL = "https://search.maven.org/solrsearch/select";
     private static final String API_URL = "https://search.maven.org/solrsearch/select";
 
 
-    private static final Gson gson;
+    private static final Gson GSON;
 
 
     static {
     static {
         JsonDeserializer<Instant> instantDeserializer = (jSon, typeOfT, context) -> jSon == null ? null : Instant.ofEpochMilli(jSon.getAsLong());
         JsonDeserializer<Instant> instantDeserializer = (jSon, typeOfT, context) -> jSon == null ? null : Instant.ofEpochMilli(jSon.getAsLong());
 
 
-        gson = new GsonBuilder()
+        GSON = new GsonBuilder()
                 .registerTypeAdapter(Instant.class, instantDeserializer).create();
                 .registerTypeAdapter(Instant.class, instantDeserializer).create();
     }
     }
 
 
@@ -84,7 +84,7 @@ public class MavenApiVersionChecker implements MavenVersionChecker {
                 return result.response.docs.stream().map((doc) -> doc.v).collect(Collectors.toList());
                 return result.response.docs.stream().map((doc) -> doc.v).collect(Collectors.toList());
             });
             });
         } catch (InterruptedException | ExecutionException ex) {
         } catch (InterruptedException | ExecutionException ex) {
-            throw new RuntimeException("Failed to get version info!", ex);
+            throw new MavenVersionCheckException("Failed to get version info!", ex);
         }
         }
     }
     }
 
 
@@ -103,7 +103,7 @@ public class MavenApiVersionChecker implements MavenVersionChecker {
                 return result.response.docs.get(0).latestVersion;
                 return result.response.docs.get(0).latestVersion;
             });
             });
         } catch (InterruptedException | ExecutionException ex) {
         } catch (InterruptedException | ExecutionException ex) {
-            throw new RuntimeException("Failed to get latest version info!", ex);
+            throw new MavenVersionCheckException("Failed to get latest version info!", ex);
         }
         }
     }
     }
 
 
@@ -123,7 +123,7 @@ public class MavenApiVersionChecker implements MavenVersionChecker {
                         throw new MavenVersionCheckException("Calling " + encodedURL + " not OK. API response " + t.statusCode() + "!");
                         throw new MavenVersionCheckException("Calling " + encodedURL + " not OK. API response " + t.statusCode() + "!");
                     }
                     }
 
 
-                    return gson.fromJson(t.body(), clazz);
+            return GSON.fromJson(t.body(), clazz);
                 });
                 });
 
 
         return result;
         return result;

+ 4 - 0
jme3-templates/src/com/jme3/gde/templates/utils/mavensearch/MavenVersionCheckException.java

@@ -40,4 +40,8 @@ public class MavenVersionCheckException extends RuntimeException {
         super(message);
         super(message);
     }
     }
 
 
+    public MavenVersionCheckException(String message, Exception cause) {
+        super(message, cause);
+    }
+
 }
 }