changeset 174:feda4d56c9a5

8081511: Unexpected IOExceptin at UARTConfig.Builder.build Summary: Intermediate UARTConfig instance is returned if Platform.clone() throws an exception Reviewed-by: alkonsta
author snazarki
date Fri, 29 May 2015 18:17:34 +0300
parents dfb0a1f399c7
children cd8f6c7683c5
files src/se/classes/com/oracle/dio/utils/ExceptionMessage.java src/share/classes/jdk/dio/uart/UARTConfig.java
diffstat 2 files changed, 11 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/se/classes/com/oracle/dio/utils/ExceptionMessage.java	Fri May 29 18:01:24 2015 +0300
+++ b/src/se/classes/com/oracle/dio/utils/ExceptionMessage.java	Fri May 29 18:17:34 2015 +0300
@@ -57,7 +57,8 @@
     public static final int DEVICE_READONLY_PERMISSION_COLLECTION    = DEVICE_FIRST + 21;
     public static final int DEVICE_OPEN_WITH_DEVICENAME_UNSUPPORTED  = DEVICE_FIRST + 22;
     public static final int BUFFER_IS_MODIFIED                       = DEVICE_FIRST + 23;
-    public static final int DEVICE_LAST = BUFFER_IS_MODIFIED;
+    public static final int CLONE_ERROR                              = DEVICE_FIRST + 24;
+    public static final int DEVICE_LAST = CLONE_ERROR;
 
     public static final int ADC_FIRST = DEVICE_LAST + 1;
     public static final int ADC_ANOTHER_OPERATION_PROGRESS           = ADC_FIRST + 0;
@@ -202,6 +203,7 @@
         "Cannot add a Permission to a readonly PermissionCollection",
         "Opening with deviceName is unsupported",
         "Buffer was modified by application",
+        "The object can't be cloned",
 
         // adc messages
         "Another operation on ADC channel is in progress",
--- a/src/share/classes/jdk/dio/uart/UARTConfig.java	Fri May 29 18:01:24 2015 +0300
+++ b/src/share/classes/jdk/dio/uart/UARTConfig.java	Fri May 29 18:17:34 2015 +0300
@@ -30,6 +30,8 @@
 import java.util.Objects;
 
 import com.oracle.dio.impl.Platform;
+import com.oracle.dio.utils.ExceptionMessage;
+import com.oracle.dio.utils.Logging;
 
 import jdk.dio.DeviceConfig;
 import jdk.dio.DeviceManager;
@@ -195,7 +197,12 @@
          */
         public UARTConfig build() {
             instance.checkParameters();
-            return (UARTConfig)Platform.clone(instance);
+            try {
+                return (UARTConfig)Platform.clone(instance);
+            } catch (IOException e) {
+                Logging.reportWarning(ExceptionMessage.format(ExceptionMessage.CLONE_ERROR));
+                return instance;
+            }
         }
 
         /**