changeset 50:be1bc081b865

8057954: IllegalStateException "combine message is empty" on attempt to end an I2C transaction Reviewed-by: raimandi Contributed-by: alexey.mironov@oracle.com
author alkonsta
date Thu, 25 Sep 2014 15:41:00 +0400
parents 4062e137c8f2
children 950002a54da8
files src/se/classes/com/oracle/dio/utils/ExceptionMessage.java src/share/classes/com/oracle/dio/i2cbus/impl/I2CCombinedMessage.java
diffstat 2 files changed, 7 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/src/se/classes/com/oracle/dio/utils/ExceptionMessage.java	Wed Sep 17 16:01:44 2014 -0400
+++ b/src/se/classes/com/oracle/dio/utils/ExceptionMessage.java	Thu Sep 25 15:41:00 2014 +0400
@@ -118,10 +118,9 @@
     public static final int I2CBUS_NEGATIVE_SKIP_ARG                 = I2CBUS_FIRST + 2;
     public static final int I2CBUS_DIFFERENT_BUS_SLAVE_OPERATION     = I2CBUS_FIRST + 3;
     public static final int I2CBUS_BUFFER_GIVEN_TWICE                = I2CBUS_FIRST + 4;
-    public static final int I2CBUS_EMPTY_COMBINE_MESSAGE             = I2CBUS_FIRST + 5;
-    public static final int I2CBUS_CLOSED_DEVICE                     = I2CBUS_FIRST + 6;
-    public static final int I2CBUS_FIRST_MESSAGE                     = I2CBUS_FIRST + 7;
-    public static final int I2CBUS_LAST_MESSAGE                      = I2CBUS_FIRST + 8;
+    public static final int I2CBUS_CLOSED_DEVICE                     = I2CBUS_FIRST + 5;
+    public static final int I2CBUS_FIRST_MESSAGE                     = I2CBUS_FIRST + 6;
+    public static final int I2CBUS_LAST_MESSAGE                      = I2CBUS_FIRST + 7;
     public static final int I2CBUS_LAST = I2CBUS_LAST_MESSAGE;
 
     public static final int MMIO_FIRST = I2CBUS_LAST + 1;
@@ -258,7 +257,6 @@
         "'skip' argument is negative",
         "operation to a slave on a different bus",
         "the same buffer is given twice",
-        "combine message is empty",
         "combined message with closed device",
         "first message",
         "last message",
--- a/src/share/classes/com/oracle/dio/i2cbus/impl/I2CCombinedMessage.java	Wed Sep 17 16:01:44 2014 -0400
+++ b/src/share/classes/com/oracle/dio/i2cbus/impl/I2CCombinedMessage.java	Thu Sep 25 15:41:00 2014 +0400
@@ -230,19 +230,16 @@
     public int[] transfer() throws IOException, UnavailableDeviceException, ClosedDeviceException {
         int bytesRead[];
         synchronized (this) {
-            if (0 == messageList.size()) {
-                throw new IllegalStateException(
-                    ExceptionMessage.format(ExceptionMessage.I2CBUS_EMPTY_COMBINE_MESSAGE)
-                );
-            }
-
             /* Forbid adding more messages to this combined message */
             isAlreadyTransferedOnce = true;
+            if (0 == messageList.size()) {
+                notifyAll();
+                return null;
+            }
 
             bytesRead = new int[rxMessageCount];
             int bytesReadIdx = 0;
 
-
             try {
                 final int size = messageList.size();
                 if (1 == size) {