Fixed random warnings

This commit is contained in:
genuineparts 2025-02-16 21:20:18 +01:00
parent e7a8f8987d
commit 8e2bb1666d
4 changed files with 18 additions and 29 deletions

View file

@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>be.jaud</groupId> <groupId>be.jaud</groupId>
<artifactId>OebbApi</artifactId> <artifactId>OebbApi</artifactId>
<version>0.1</version> <version>0.5</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>ÖBB delay check and output for Info Orbs</name> <name>ÖBB delay check and output for Info Orbs</name>
<properties> <properties>

View file

@ -67,6 +67,11 @@ public class OebbCheck {
private static JSONArray getData(String Station, String Time, String maxjourneys) throws IOException, URISyntaxException { private static JSONArray getData(String Station, String Time, String maxjourneys) throws IOException, URISyntaxException {
URL url = new URI("https://fahrplan.oebb.at/bin/stboard.exe/dn?L=vs_scotty.vs_liveticker&evaId=" + Station + "&boardType=dep&time="+ Time +"&productsFilter=1011110111011&additionalTime=0&maxJourneys=" + maxjourneys + "&outputMode=tickerDataOnly&start=yes&selectDate=today").toURL(); URL url = new URI("https://fahrplan.oebb.at/bin/stboard.exe/dn?L=vs_scotty.vs_liveticker&evaId=" + Station + "&boardType=dep&time="+ Time +"&productsFilter=1011110111011&additionalTime=0&maxJourneys=" + maxjourneys + "&outputMode=tickerDataOnly&start=yes&selectDate=today").toURL();
JSONObject jo = getJsonObject(url);
return jo.getJSONArray("journey");
}
private static JSONObject getJsonObject(URL url) throws IOException {
HttpURLConnection con = (HttpURLConnection) url.openConnection(); HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("GET"); con.setRequestMethod("GET");
BufferedReader in = new BufferedReader( BufferedReader in = new BufferedReader(
@ -78,7 +83,6 @@ public class OebbCheck {
} }
in.close(); in.close();
String sub = content.substring(14); String sub = content.substring(14);
JSONObject jo = new JSONObject(sub); return new JSONObject(sub);
return jo.getJSONArray("journey");
} }
} }

View file

@ -29,23 +29,17 @@ public class ResilientExecutor extends ScheduledThreadPoolExecutor {
return new LogOnExceptionRunnable(command); return new LogOnExceptionRunnable(command);
} }
private static class LogOnExceptionRunnable implements Runnable { private record LogOnExceptionRunnable(Runnable theRunnable) implements Runnable {
private final Runnable theRunnable;
public LogOnExceptionRunnable(Runnable theRunnable) {
super();
this.theRunnable = theRunnable;
}
@Override @Override
public void run() { public void run() {
try { try {
theRunnable.run(); theRunnable.run();
} catch (Exception e) { } catch (Exception e) {
LOG.error("error in executing: {} It will no longer be run!", this.theRunnable, e); LOG.error("error in executing: {} It will no longer be run!", this.theRunnable, e);
System.exit(1); System.exit(1);
}
} }
} }
}
} }

View file

@ -2,14 +2,11 @@ package be.jaud;
import java.io.File; import java.io.File;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map.Entry;
import com.typesafe.config.Config; import com.typesafe.config.Config;
import com.typesafe.config.ConfigException; import com.typesafe.config.ConfigException;
import com.typesafe.config.ConfigFactory; import com.typesafe.config.ConfigFactory;
import com.typesafe.config.ConfigValue;
public class Settings { public class Settings {
private static Settings instance = null; private static Settings instance = null;
@ -30,25 +27,19 @@ public class Settings {
} }
} }
public Iterator<Entry<String, ConfigValue>> getall(){ //public Iterator<Entry<String, ConfigValue>> getall(){ return config.entrySet().iterator(); }
return config.entrySet().iterator();
}
public String getString(String key){ public String getString(String key){
return config.getString(key); return config.getString(key);
} }
public Boolean getBoolean(String key){ //public Boolean getBoolean(String key){ return config.getBoolean(key); }
return config.getBoolean(key);
}
public int getInt(String key){ public int getInt(String key){
return config.getInt(key); return config.getInt(key);
} }
public List<String> getStringList(String key){ //public List<String> getStringList(String key){ return config.getStringList(key); }
return config.getStringList(key);
}
public List<Integer> getIntList(String key){ return config.getIntList(key); } public List<Integer> getIntList(String key){ return config.getIntList(key); }
} }