You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by sv...@apache.org on 2006/12/18 11:19:56 UTC
svn commit: r488197 -
/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/PassByValueInterceptor.java
Author: svkrish
Date: Mon Dec 18 02:19:55 2006
New Revision: 488197
URL: http://svn.apache.org/viewvc?view=rev&rev=488197
Log:
Fixed to catch the specialized exceptions than base java.lang.Exception
Modified:
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/PassByValueInterceptor.java
Modified: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/PassByValueInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/PassByValueInterceptor.java?view=diff&rev=488197&r1=488196&r2=488197
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/PassByValueInterceptor.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/PassByValueInterceptor.java Mon Dec 18 02:19:55 2006
@@ -131,19 +131,28 @@
return null;
}
+ ByteArrayOutputStream bos = null;
+ ObjectOutputStream oos = null;
+
try {
if (arg instanceof Serializable) {
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- ObjectOutputStream oos = getObjectOutputStream(bos);
+ bos = new ByteArrayOutputStream();
+ oos = getObjectOutputStream(bos);
oos.writeObject(arg);
- oos.close();
- bos.close();
+
return bos.toByteArray();
} else {
throw new IllegalArgumentException("Unable to serialize using Java Serialization");
}
- } catch (Exception e) {
+ } catch (IOException e) {
throw new IllegalArgumentException("Exception while serializing argument ", e);
+ } finally {
+ try {
+ oos.close();
+ bos.close();
+ } catch ( IOException e ) {
+ throw new IllegalArgumentException("Exception while serializing argument ", e);
+ }
}
}
@@ -156,15 +165,27 @@
// Immutable classes
return arg;
}
+
+ ByteArrayInputStream bis = null;
+ ObjectInputStream ois = null;
+
try {
- ByteArrayInputStream bis = new ByteArrayInputStream((byte[])arg);
- ObjectInputStream ois = getObjectInputStream(bis, clazz.getClassLoader());
+ bis = new ByteArrayInputStream((byte[])arg);
+ ois = getObjectInputStream(bis, clazz.getClassLoader());
Object objectCopy = ois.readObject();
- ois.close();
- bis.close();
+
return objectCopy;
- } catch (Exception e) {
+ } catch (IOException e) {
+ throw new IllegalArgumentException("Exception when attempting to Java Deserialization of object ", e);
+ } catch (ClassNotFoundException e) {
throw new IllegalArgumentException("Exception when attempting to Java Deserialization of object ", e);
+ } finally {
+ try {
+ ois.close();
+ bis.close();
+ } catch ( IOException e ) {
+ throw new IllegalArgumentException("Exception when attempting to Java Deserialization of object ", e);
+ }
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org