fix some warnings
This commit is contained in:
		| @@ -7,8 +7,8 @@ public abstract class DataPoint{ | ||||
|  | ||||
|  | ||||
|     public static Map<String, DataPoint> dataPointMap = new HashMap<>(); // Map of all DataPoints | ||||
|     private String label; // Label of this DataPoint | ||||
|     private boolean isOutput; // True if this DataPoint is an output, false if it's an input | ||||
|     private final String label; // Label of this DataPoint | ||||
|     private final boolean isOutput; // True if this DataPoint is an output, false if it's an input | ||||
|  | ||||
|     /** | ||||
|      * Constructor of DataPoint | ||||
|   | ||||
| @@ -15,12 +15,13 @@ import java.net.HttpURLConnection; | ||||
| import java.net.MalformedURLException; | ||||
| import java.net.ProtocolException; | ||||
| import java.net.URL; | ||||
| import java.nio.file.Files; | ||||
| import java.nio.file.Paths; | ||||
| import java.util.Properties; | ||||
|  | ||||
|  | ||||
| public class DatabaseConnector implements DataPointListener { | ||||
|     private final Properties properties = new Properties();           // Properties of the config.properties file | ||||
|     private String fullURL = null;                              // Full URL of the InfluxDB server | ||||
|     private URL urlForWrite = null;                             // URL of the InfluxDB server | ||||
|     private HttpURLConnection con = null;                       // Connection to the InfluxDB server | ||||
|     private boolean initialized = false;                        // Boolean to know if the database connector is initialized | ||||
| @@ -40,7 +41,7 @@ public class DatabaseConnector implements DataPointListener { | ||||
|      */ | ||||
|     private DatabaseConnector (){ | ||||
|         // Read the config.properties file | ||||
|         try (InputStream input = new FileInputStream("src/config.properties")) { | ||||
|         try (InputStream input = Files.newInputStream(Paths.get("src/config.properties"))) { | ||||
|             properties.load(input); | ||||
|         } catch (Exception e) { | ||||
|             e.printStackTrace(); | ||||
| @@ -77,6 +78,8 @@ public class DatabaseConnector implements DataPointListener { | ||||
|      * @param url URL of the database. If null take the URL from the config.properties file | ||||
|      */ | ||||
|     public void initialize(String url){ | ||||
|         // Full URL of the InfluxDB server | ||||
|         String fullURL = null; | ||||
|         try{ | ||||
|             if(urlForWrite == null){ | ||||
|                 if(url == null){ | ||||
| @@ -106,10 +109,6 @@ public class DatabaseConnector implements DataPointListener { | ||||
|                 con.setRequestProperty("Content-Type", "text/plain"); | ||||
|                 con.setRequestProperty("Accept", "application/json"); | ||||
|                 con.setDoOutput(true); | ||||
|             } catch (MalformedURLException e) { | ||||
|                 throw new RuntimeException(e); | ||||
|             } catch (ProtocolException e) { | ||||
|                 throw new RuntimeException(e); | ||||
|             } catch (IOException e) { | ||||
|                 throw new RuntimeException(e); | ||||
|             } | ||||
| @@ -122,7 +121,7 @@ public class DatabaseConnector implements DataPointListener { | ||||
|             data += "}"; | ||||
|             Utility.pDebug(data); | ||||
|             sendDataToDatabase(data); | ||||
|             fullURL=null;   // Reset the full URL | ||||
|             fullURL =null;   // Reset the full URL | ||||
|         } | ||||
|     } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user