changeset 92:9753293dba56

8069369: Findbugs High Priority Warnings in DIO Summary: Small changes to avoid warnings Reviewed-by: snazarki
author amironov
date Thu, 29 Jan 2015 17:32:48 +0300
parents 0500a43b8c22
children d61f9ce3dacd
files src/se/classes/com/oracle/dio/gpio/impl/GPIOPortRegistryFactory.java src/se/classes/com/oracle/dio/registry/RegistryData.java src/se/classes/com/oracle/dio/registry/RegistryImpl.java src/se/classes/com/oracle/dio/utils/Configuration.java
diffstat 4 files changed, 7 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/se/classes/com/oracle/dio/gpio/impl/GPIOPortRegistryFactory.java	Wed Jan 28 15:24:59 2015 +0300
+++ b/src/se/classes/com/oracle/dio/gpio/impl/GPIOPortRegistryFactory.java	Thu Jan 29 17:32:48 2015 +0300
@@ -59,7 +59,7 @@
         Enumeration<?> pins = pinList.elements();
         for (int i = 0; pins.hasMoreElements(); i++) {
             RegistryData pin = (RegistryData)pins.nextElement();
-            pin = (RegistryData)pin.clone();
+            pin = pin.cloneRegistryData();
             pin.putIntegerProperty(Constants.DIRECTION, dir);
             parray[i] = GPIOPinRegistryFactory.createConfig(pin);
         }
--- a/src/se/classes/com/oracle/dio/registry/RegistryData.java	Wed Jan 28 15:24:59 2015 +0300
+++ b/src/se/classes/com/oracle/dio/registry/RegistryData.java	Thu Jan 29 17:32:48 2015 +0300
@@ -146,8 +146,7 @@
         return output.toString();
     }
 
-    @Override
-    public Object clone() {
+    public RegistryData cloneRegistryData() {
         return new RegistryData((Hashtable<String, Object>)data.clone());
     }
 }
--- a/src/se/classes/com/oracle/dio/registry/RegistryImpl.java	Wed Jan 28 15:24:59 2015 +0300
+++ b/src/se/classes/com/oracle/dio/registry/RegistryImpl.java	Thu Jan 29 17:32:48 2015 +0300
@@ -52,6 +52,7 @@
 
     private static final String REGISTRY_FILE_PATH = "jdk.dio.registry";
     private static final String PREDEFINED = "predefined";
+    private static final String DEFAULT_CHARSET_NAME = "UTF-8";
 
     protected static final boolean canRegister = true;
 
@@ -144,7 +145,7 @@
             try {
                 String path = Configuration.getSystemProperty(REGISTRY_FILE_PATH);
                 if (path != null) {
-                    registry.load(new InputStreamReader(new FileInputStream(path)));
+                    registry.load(new InputStreamReader(new FileInputStream(path), DEFAULT_CHARSET_NAME));
                 }
             } catch (IOException | SecurityException | IllegalArgumentException e) {
                 registry.clear();
@@ -159,7 +160,7 @@
         if (path == null) {
             throw new IOException("Registry is not available");
         }
-        registry.store(new OutputStreamWriter(new FileOutputStream(path)), null);
+        registry.store(new OutputStreamWriter(new FileOutputStream(path), DEFAULT_CHARSET_NAME), null);
     }
 
     private RegistryContent readRegistryContent(Properties registry) {
@@ -302,7 +303,7 @@
         }
         RegistryData defaults = content.getType(type);
         if (defaults != null) {
-            config = (RegistryData)config.clone();
+            config = config.cloneRegistryData();
             Enumeration<String> keys = defaults.keys();
             while (keys.hasMoreElements()) {
                 String key = (String)keys.nextElement();
--- a/src/se/classes/com/oracle/dio/utils/Configuration.java	Wed Jan 28 15:24:59 2015 +0300
+++ b/src/se/classes/com/oracle/dio/utils/Configuration.java	Thu Jan 29 17:32:48 2015 +0300
@@ -149,7 +149,7 @@
         String value = getPropertyDefault(key, null);
         if (value != null) {
             try {
-                return Integer.valueOf(value).intValue();
+                return Integer.parseInt(value);
             } catch (NumberFormatException e) {
             }
         }