summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorxma2007-08-03 04:36:58 (EDT)
committerxgu2007-08-03 04:36:58 (EDT)
commit6ab5c9bf390504149b0676d44aeeaba8a875a88c (patch)
tree7f3d7884c7735b431a0e1fe5b5f90acf05ea3474
parentca9f470dcb05aafb51ed3cd51940c9fc1c04e6de (diff)
downloadorg.eclipse.datatools.enablement.oda-6ab5c9bf390504149b0676d44aeeaba8a875a88c.zip
org.eclipse.datatools.enablement.oda-6ab5c9bf390504149b0676d44aeeaba8a875a88c.tar.gz
org.eclipse.datatools.enablement.oda-6ab5c9bf390504149b0676d44aeeaba8a875a88c.tar.bz2
Fix Bugzilla – Bug 196996
RawMessageSender.java - This is going to peg the CPU - Code Reviewed Using SofCheck Inspector
-rw-r--r--plugins/org.eclipse.datatools.enablement.oda.ws.ui/src/org/eclipse/datatools/enablement/oda/ws/ui/util/WSConsole.java18
-rw-r--r--plugins/org.eclipse.datatools.enablement.oda.ws/src/org/eclipse/datatools/enablement/oda/ws/impl/Query.java14
-rw-r--r--plugins/org.eclipse.datatools.enablement.oda.ws/src/org/eclipse/datatools/enablement/oda/ws/util/RawMessageSender.java12
-rw-r--r--plugins/org.eclipse.datatools.enablement.oda.ws/src/org/eclipse/datatools/enablement/oda/ws/util/WSUtil.java14
-rw-r--r--tests/org.eclipse.datatools.enablement.oda.ws.test/test/org/eclipse/datatools/enablement/oda/ws/misc/RawMessageSenderTest.java2
5 files changed, 47 insertions, 13 deletions
diff --git a/plugins/org.eclipse.datatools.enablement.oda.ws.ui/src/org/eclipse/datatools/enablement/oda/ws/ui/util/WSConsole.java b/plugins/org.eclipse.datatools.enablement.oda.ws.ui/src/org/eclipse/datatools/enablement/oda/ws/ui/util/WSConsole.java
index 2c046f1..7b87829 100644
--- a/plugins/org.eclipse.datatools.enablement.oda.ws.ui/src/org/eclipse/datatools/enablement/oda/ws/ui/util/WSConsole.java
+++ b/plugins/org.eclipse.datatools.enablement.oda.ws.ui/src/org/eclipse/datatools/enablement/oda/ws/ui/util/WSConsole.java
@@ -12,6 +12,7 @@
package org.eclipse.datatools.enablement.oda.ws.ui.util;
import java.io.BufferedInputStream;
+import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
@@ -183,6 +184,12 @@ public class WSConsole
setPropertyValue( Constants.CUSTOM_CONNECTION_CLASS,
customConnectionClass == null ? WSUIUtil.EMPTY_STRING
: customConnectionClass.getValue( ) );
+
+ Property connectionTimeOut = dataSourceDesign.getPublicProperties( )
+ .findProperty( Constants.CONNECTION_TIMEOUT );
+ setPropertyValue( Constants.CONNECTION_TIMEOUT,
+ connectionTimeOut == null ? "0" //$NON-NLS-1$
+ : connectionTimeOut.getValue( ) );
}
if ( dataSourceDesign.getPrivateProperties( ) != null )
{
@@ -411,7 +418,14 @@ public class WSConsole
try
{
j2s.newQuery( getPropertyValue( Constants.CUSTOM_CONNECTION_CLASS ) );
- return (InputStream) j2s.executeQuery( );
+
+ Object o = j2s.executeQuery( );
+ if ( o instanceof InputStream )
+ return (InputStream) o;
+ else if ( o instanceof String )
+ return new ByteArrayInputStream( o.toString( ).getBytes( ) );
+
+ return null;
}
catch ( Exception e )
{
@@ -454,7 +468,7 @@ public class WSConsole
RawMessageSender rawMessageSender = new RawMessageSender( spec,
message,
soapAction );
- SOAPResponse soapResponse = rawMessageSender.getSOAPResponse( );
+ SOAPResponse soapResponse = rawMessageSender.getSOAPResponse( WSUIUtil.parseLong( getPropertyValue( Constants.CONNECTION_TIMEOUT ) ) );
return soapResponse;
}
diff --git a/plugins/org.eclipse.datatools.enablement.oda.ws/src/org/eclipse/datatools/enablement/oda/ws/impl/Query.java b/plugins/org.eclipse.datatools.enablement.oda.ws/src/org/eclipse/datatools/enablement/oda/ws/impl/Query.java
index 6884032..284ca48 100644
--- a/plugins/org.eclipse.datatools.enablement.oda.ws/src/org/eclipse/datatools/enablement/oda/ws/impl/Query.java
+++ b/plugins/org.eclipse.datatools.enablement.oda.ws/src/org/eclipse/datatools/enablement/oda/ws/impl/Query.java
@@ -61,12 +61,14 @@ public class Query implements IQuery
private String soapEndPoint = WSUtil.EMPTY_STRING;
private String operationTrace = WSUtil.EMPTY_STRING;
private String wsdlURI = WSUtil.EMPTY_STRING;
+ private long connectionTimeout;
public Query( RawMessageSender rawMessageSender, Properties connProperties )
{
this.rawMessageSender = rawMessageSender;
this.wsdlURI = ( (Properties) connProperties ).getProperty( Constants.WSDL_URI );
this.soapEndPoint = ( (Properties) connProperties ).getProperty( Constants.SOAP_ENDPOINT );
+ this.connectionTimeout = WSUtil.parseLong( ( (Properties) connProperties ).getProperty( Constants.CONNECTION_TIMEOUT ) );
this.m_maxRows = 0;
}
@@ -164,7 +166,7 @@ public class Query implements IQuery
rawMessageSender.setSpec( WSUtil.getNonNullString( soapEndPoint ) );
rawMessageSender.setSoapAction( WSUtil.getNonNullString( WSDLAdvisor.getSOAPActionURI( wsdlURI,
operationTrace ) ) );
- SOAPResponse soapResponse = rawMessageSender.getSOAPResponse( );
+ SOAPResponse soapResponse = rawMessageSender.getSOAPResponse( connectionTimeout );
if ( WSUtil.isNull( soapResponse ) )
return null;
@@ -178,13 +180,11 @@ public class Query implements IQuery
try
{
Object o = java2SOAPManager.executeQuery( );
- if( o instanceof InputStream )
- return (InputStream)o;
- else if( o instanceof String )
- {
+ if ( o instanceof InputStream )
+ return (InputStream) o;
+ else if ( o instanceof String )
return new ByteArrayInputStream( o.toString( ).getBytes( ) );
- }
-
+
return null;
}
catch ( Exception e )
diff --git a/plugins/org.eclipse.datatools.enablement.oda.ws/src/org/eclipse/datatools/enablement/oda/ws/util/RawMessageSender.java b/plugins/org.eclipse.datatools.enablement.oda.ws/src/org/eclipse/datatools/enablement/oda/ws/util/RawMessageSender.java
index 9ff59b9..d3c6411 100644
--- a/plugins/org.eclipse.datatools.enablement.oda.ws/src/org/eclipse/datatools/enablement/oda/ws/util/RawMessageSender.java
+++ b/plugins/org.eclipse.datatools.enablement.oda.ws/src/org/eclipse/datatools/enablement/oda/ws/util/RawMessageSender.java
@@ -82,13 +82,19 @@ public class RawMessageSender
/**
*
+ * @param timeout
* @return
*/
- public SOAPResponse getSOAPResponse( )
+ public SOAPResponse getSOAPResponse( long timeout )
{
Thread t = new Thread( new SOAPResponseCollector( ) );
t.start( );
- while ( t.isAlive( ) )
+ try
+ {
+ timeout = timeout == 0 ? 0 : Math.max( 60000, timeout );
+ t.join( timeout );
+ }
+ catch ( InterruptedException e )
{
}
@@ -108,7 +114,7 @@ public class RawMessageSender
connection.setRequestMethod( "POST" ); //$NON-NLS-1$
connection.setRequestProperty( "Content-Length", //$NON-NLS-1$
String.valueOf( message.length( ) ) );
- connection.setRequestProperty( "Content-Type", "text/xml" ); //$NON-NLS-1$//$NON-NLS-2$
+ connection.setRequestProperty( "Content-Type", "text/xml" ); //$NON-NLS-1$//$NON-NLS-2$
connection.setRequestProperty( "Connection", "Close" ); //$NON-NLS-1$ //$NON-NLS-2$
connection.setRequestProperty( "SoapAction", soapAction ); //$NON-NLS-1$
connection.setDoOutput( true );
diff --git a/plugins/org.eclipse.datatools.enablement.oda.ws/src/org/eclipse/datatools/enablement/oda/ws/util/WSUtil.java b/plugins/org.eclipse.datatools.enablement.oda.ws/src/org/eclipse/datatools/enablement/oda/ws/util/WSUtil.java
index 8c6e657..576a2e6 100644
--- a/plugins/org.eclipse.datatools.enablement.oda.ws/src/org/eclipse/datatools/enablement/oda/ws/util/WSUtil.java
+++ b/plugins/org.eclipse.datatools.enablement.oda.ws/src/org/eclipse/datatools/enablement/oda/ws/util/WSUtil.java
@@ -49,4 +49,18 @@ public class WSUtil
return value == null ? EMPTY_STRING : value;
}
+ /**
+ * Parses the string argument as a signed decimal <code>long</code>.
+ *
+ * @param string
+ * @return 0 if the argument is null or empty string
+ */
+ public static long parseLong( String string )
+ {
+ if ( WSUtil.isNull( string ) )
+ return 0;
+
+ return Long.parseLong( string );
+ }
+
}
diff --git a/tests/org.eclipse.datatools.enablement.oda.ws.test/test/org/eclipse/datatools/enablement/oda/ws/misc/RawMessageSenderTest.java b/tests/org.eclipse.datatools.enablement.oda.ws.test/test/org/eclipse/datatools/enablement/oda/ws/misc/RawMessageSenderTest.java
index 21f74ca..7f36dc3 100644
--- a/tests/org.eclipse.datatools.enablement.oda.ws.test/test/org/eclipse/datatools/enablement/oda/ws/misc/RawMessageSenderTest.java
+++ b/tests/org.eclipse.datatools.enablement.oda.ws.test/test/org/eclipse/datatools/enablement/oda/ws/misc/RawMessageSenderTest.java
@@ -63,7 +63,7 @@ public class RawMessageSenderTest extends BaseTest
message,
soapAction );
- assertEquals( 0, rms.getSOAPResponse( ).getStreamType( ) );
+ assertEquals( 0, rms.getSOAPResponse( 0 ).getStreamType( ) );
}
}