-
Bug
-
Resolution: Unresolved
-
P4
-
None
-
8
-
generic
-
generic
ADDITIONAL SYSTEM INFORMATION :
+ Windows 10
+ JRE version 1.8.0_311
+ Applet
+ HTTPS via proxy
A DESCRIPTION OF THE PROBLEM :
Our Applet, in some network configuration, randomly get hanged on HTTP request.
the exact same HTTP request (for this random hanging), responded perfectly before, and also on other next trying.
we are using the Applet in network with a proxy definition (browser definition)
After the 30 second hanging, eventually our client got the : java.net.SocketException: Unexpected end of file from server
This exception, is due to the fact the the server waiting for the client payload (body data and/or content-length) that probably not provided by the HttpURLConnection.
From our client perspective, all the data provided in the OutputStream of the connection.
in order to confirm it , we added special decorator class TraceOutputStream, that will "trace" the actual content for the request.
and we can see it in the log.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
provided a small demonstration Applet, that extracted from our original Applet code.
+ in the "Expected Result" you can find two cases of a valid request and response using two different endpoints
+ in the "Actual Result" you can find one case of invalid response, that randomly occurs.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
----------------------------------------------------
====> here is a case of valid result:
######Connection URL https://imexuat3-o1.sp.uat.dbs.corp:7743/imexuat3_o1/ImexServlet?LP
######Request Payload content Stream created.
....t..legacyRequestur..[Ljava.lang.Object;..X..s)l...xp....sr..imex.util.ImexMenuAction...........L..transAreat..Ljava/lang/String;L..winsetq.~..xpt..011t..ILCISSNEpt..IXMMN01sr..imex.util.LegacyUserDetails...........I..diagnosticStatusJ..loginTimestampL..encodingq.~..L..entityq.~..L..hostAddressq.~..L..terminalIDq.~..L..userIdq.~..L..userPasswordq.~..xp........fb..pt..001t..10.4.239.163t..K003t..MADHAVIKt..$$
Stream flushed.
Stream closed.
content-length=414
######Response Header Fields {Transfer-Encoding=[chunked], null=[HTTP/1.1 200 OK], Server=[JBoss-EAP/7], X-Content-Type-Options=[NOSNIFF], Connection=[keep-alive], Date=[Thu, 04 Aug 2022 01:15:38 GMT], Referrer-Policy=[no-referrer], X-Frame-Options=[DENY], Strict-Transport-Security=[max-age=31536000; includeSubDomains], Content-Security-Policy=[default-src 'self'], X-XSS-Protection=[1; mode=block], Content-Type=[application/octet-stream], X-Powered-By=[Undertow/1]}
######Respose ContentType application/octet-stream
######Respose going to read Object from stream...
######Respose going to close InputStream...
######Respose InputStream closed.
----------------------------------------------------
====> here is another case of valid result with the same endpoint that failed in the other case :
######Connection URL https://imexuat3-o1.sp.uat.dbs.corp:7743/imexuat3_o1/ImexServlet?SDGW
######Request Payload content Stream created.
....t..getDataEntryByKeyur..[Ljava.lang.Object;..X..s)l...xp....t..001t..AP532t..670t..Bt..MADHAVIKsr..java.lang.Integer.......8...I..valuexr..java.lang.Number...........xp....
Stream flushed.
Stream closed.
content-length=176
######Response Header Fields {Transfer-Encoding=[chunked], null=[HTTP/1.1 200 OK], Server=[JBoss-EAP/7], X-Content-Type-Options=[NOSNIFF], Connection=[keep-alive], Date=[Thu, 04 Aug 2022 01:15:38 GMT], Referrer-Policy=[no-referrer], X-Frame-Options=[DENY], Strict-Transport-Security=[max-age=31536000; includeSubDomains], Content-Security-Policy=[default-src 'self'], X-XSS-Protection=[1; mode=block], Content-Type=[application/octet-stream], X-Powered-By=[Undertow/1]}
######Respose ContentType application/octet-stream
######Respose going to read Object from stream...
######Respose going to close InputStream...
######Respose InputStream closed.
----------------------------------------------------
ACTUAL -
----------------------------------------------------
====> here is a case of failure after 30 second of hanging:
######Connection URL https://imexuat3-o1.sp.uat.dbs.corp:7743/imexuat3_o1/ImexServlet?SDGW
######Request Payload content Stream created.
....t..getDataEntryByKeyur..[Ljava.lang.Object;..X..s)l...xp....t..001t..AP532t..469t..Bt..MADHAVIKsr..java.lang.Integer.......8...I..valuexr..java.lang.Number...........xp....
Stream flushed.
Stream closed.
content-length=176
######Response Header Fields {}
######Respose Throwable Unexpected end of file from server
java.net.SocketException: Unexpected end of file from server
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection$10.run(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection$10.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.net.www.protocol.http.HttpURLConnection.getChainedException(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.access$200(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection$9.run(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection$9.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessController.doPrivilegedWithCombiner(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(Unknown Source)
at imex.client.framework.MainWindow.servletToObject(MainWindow.java:2443)
at imex.client.framework.MainWindow.objectArrayToServlet(MainWindow.java:2074)
at imex.client.framework.SDGWConnector.executeServlet(SDGWConnector.java:166)
at imex.client.framework.SDGWConnector.executeSdgwService(SDGWConnector.java:134)
at imex.client.framework.DBController.execute(DBController.java:506)
at imex.client.framework.DBController.getDataEntryByKey(DBController.java:1801)
at imex.client.framework.DBController.getDataEntryByKey(DBController.java:1774)
at imex.client.framework.DBController.getDataEntryByKey(DBController.java:1763)
at imex.client.framework.DBController.getFirstCharFromTableEntry(DBController.java:7244)
at imex.client.framework.MainWindow.setDisplayMessageOnPanel(MainWindow.java:2627)
at imex.client.framework.ClientController.init(ClientController.java:1183)
at imex.client.framework.SessionController.startMenuCommand(SessionController.java:830)
at imex.client.framework.menu.MenuController.menuAction(MenuController.java:324)
at imex.client.framework.menu.ImexMenuSkin.actionPerformed(ImexMenuSkin.java:50)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.AbstractButton.doClick(Unknown Source)
at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)
at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.net.SocketException: Unexpected end of file from server
at sun.net.www.http.HttpClient.parseHTTPHeader(Unknown Source)
at sun.net.www.http.HttpClient.parseHTTP(Unknown Source)
at sun.net.www.http.HttpClient.parseHTTPHeader(Unknown Source)
at sun.net.www.http.HttpClient.parseHTTP(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.access$200(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection$9.run(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection$9.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessController.doPrivilegedWithCombiner(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getHeaderFields(Unknown Source)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getHeaderFields(Unknown Source)
at imex.client.framework.MainWindow.objectArrayToServlet(MainWindow.java:2065)
... 50 more
----------------------------------------------------
---------- BEGIN SOURCE ----------
=====================================
File #1:
package imex.network.tester;
import java.io.EOFException;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.io.StreamCorruptedException;
import java.net.URL;
import java.net.URLConnection;
class Monitoring {
private enum ServletName{LP, SDGW};
private static final boolean TRACE_OUTPUT_PAYLOAD = true;
private String servletHost;
public Monitoring(String servletHost) {
this.servletHost = servletHost;
}
/*
some housekeeping handling
*/
private void logger(String msg){
System.out.println("######" + msg);
}
public boolean monitor() {
Object result1 = null;
try {
result1 = (String) objectArrayToServlet("getDescByCode", new Object[]{"001", "AP008", "USD",(String) null}, ServletName.SDGW);
} catch (Throwable e1) {
e1.printStackTrace();
}
Object result2 = null;
try {
result2 = (Integer) objectArrayToServlet("getFieldLength", new Object[]{"H-WINSET-ID"}, ServletName.LP);
} catch (Throwable e1) {
e1.printStackTrace();
}
return result1 != null && result2 != null;
}
private Object objectArrayToServlet(String methodName, Object[] objectArray, ServletName servletType) throws Throwable
{
URLConnection servletConnection = null;
switch(servletType) {
case SDGW:
{
URL sdgwURL = new URL(servletHost + "ImexHTTPServlet?SDGW");
servletConnection = sdgwURL.openConnection();
break;
}
case LP:
{
URL lpURL = new URL(servletHost + "ImexHTTPServlet?LP");
servletConnection = lpURL.openConnection();
break;
}
}
return objectArrayToServletImpl(servletConnection, methodName, objectArray, servletType);
}
/*
here start the actual HTTP handling
*/
private Object objectArrayToServletImpl(URLConnection servletConnection, String methodName, Object[] objectArray, ServletName servletType) throws Throwable
{
logger("Connection URL " + servletConnection.getURL());
ObjectOutputStream outputToServlet = null;
// properties setting needed to be able to send binary
servletConnection.setDoInput(true);
servletConnection.setDoOutput(true);
servletConnection.setUseCaches(false);
servletConnection.setRequestProperty("Content-Type", "application/octet-stream");
// creating the outputstream to be able to send out parameters
OutputStream out = servletConnection.getOutputStream();
// use decorator Stream in order to log the actual output
if (TRACE_OUTPUT_PAYLOAD) out = new TraceOutputStream(out);
outputToServlet = new ObjectOutputStream(out);
outputToServlet.writeObject(methodName);
outputToServlet.writeObject(objectArray);
if(servletType == ServletName.SDGW) {
outputToServlet.writeObject("NetTest");
outputToServlet.writeObject(Integer.valueOf(3));
}
outputToServlet.flush();
//closing the stream
outputToServlet.close();
if (TRACE_OUTPUT_PAYLOAD) logger("Request Payload content " + ((TraceOutputStream)out).getTrace());
logger("Response Header Fields " + servletConnection.getHeaderFields());
// calling the serletToObject method that get from the servlet an object and return it to this method
// returning the object to the method that called it
return servletToObject(servletConnection,servletType);
}
private Object servletToObject(URLConnection servletConnection, ServletName servletType) throws Throwable
{
Object b = null;
//reading the object should nothing be returned we will fall on EOF
try {
InputStream is = servletConnection.getInputStream();
String contentType = servletConnection.getContentType();
logger("Respose ContentType " + contentType);
ObjectInputStream inputFromServlet = new ObjectInputStream(is);
logger("Respose going to read Object from stream...");
b = inputFromServlet.readObject();
// closing the stream
logger("Respose going to close InputStream...");
inputFromServlet.close();
logger("Respose InputStream closed.");
}
catch (StreamCorruptedException e){
logger("Respose StreamCorruptedException " + e.getMessage());
throw e;
}
catch (EOFException e){
logger("Respose EOFException " + e.getMessage());
throw e;
}
//checking if an Exception was send from the servlet
if (b instanceof Throwable){
logger("servletToObject Throwable " + ((Throwable)b).getMessage());
throw (Throwable)b;
}
//returning the Object
return b;
}
}
=====================================
File #2:
package imex.network.tester;
import java.io.IOException;
import java.io.OutputStream;
class TraceOutputStream extends OutputStream {
private final StringBuilder buff;
private final OutputStream out;
private int len = 0;
private boolean closed = false;
private boolean flushed = false;
public TraceOutputStream(OutputStream out) {
this.out = out;
buff = new StringBuilder();
buff.append("Stream created.\n");
}
@Override
public void write(int b) throws IOException {
out.write(b);
len++;
if (b < 32){
b = '.';
}
buff.append((char)b);
}
@Override
public void flush() throws IOException {
out.flush();
if (! flushed){
buff.append("\nStream flushed.");
flushed = true;
}
}
@Override
public void close() throws IOException {
out.close();
if (! closed){
buff.append("\nStream closed.");
closed = true;
}
}
String getTrace(){
return buff.toString() + "\ncontent-length=" + len;
}
}
=====================================
File #3:
package imex.network.tester;
import java.applet.Applet;
import java.awt.Dimension;
import javax.swing.JLabel;
import javax.swing.JButton;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class MainWindow extends Applet {
@Override
public void init() {
this.setSize(new Dimension(400, 100));
this.setLayout(null);
final JLabel lbl = new JLabel("");
lbl.setBounds(new Rectangle(20, 44, 400, 20));
this.add(lbl, null);
final JButton btn = new JButton("Start");
btn.setBounds(new Rectangle(20, 14, 70, 24));
final String codeBase = getCodeBase().toString();
lbl.setText("CodeBase: " + codeBase);
btn.addActionListener(new ActionListener() {
@Override public void actionPerformed(ActionEvent e) {
boolean resutl = new Monitoring(codeBase).monitor();
lbl.setText("Result => " + resutl);
}
});
this.add(btn, null);
}
}
=====================================
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
turn off the Proxy mode (which is unacceptable by our Network and Security teams)
FREQUENCY : occasionally
+ Windows 10
+ JRE version 1.8.0_311
+ Applet
+ HTTPS via proxy
A DESCRIPTION OF THE PROBLEM :
Our Applet, in some network configuration, randomly get hanged on HTTP request.
the exact same HTTP request (for this random hanging), responded perfectly before, and also on other next trying.
we are using the Applet in network with a proxy definition (browser definition)
After the 30 second hanging, eventually our client got the : java.net.SocketException: Unexpected end of file from server
This exception, is due to the fact the the server waiting for the client payload (body data and/or content-length) that probably not provided by the HttpURLConnection.
From our client perspective, all the data provided in the OutputStream of the connection.
in order to confirm it , we added special decorator class TraceOutputStream, that will "trace" the actual content for the request.
and we can see it in the log.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
provided a small demonstration Applet, that extracted from our original Applet code.
+ in the "Expected Result" you can find two cases of a valid request and response using two different endpoints
+ in the "Actual Result" you can find one case of invalid response, that randomly occurs.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
----------------------------------------------------
====> here is a case of valid result:
######Connection URL https://imexuat3-o1.sp.uat.dbs.corp:7743/imexuat3_o1/ImexServlet?LP
######Request Payload content Stream created.
....t..legacyRequestur..[Ljava.lang.Object;..X..s)l...xp....sr..imex.util.ImexMenuAction...........L..transAreat..Ljava/lang/String;L..winsetq.~..xpt..011t..ILCISSNEpt..IXMMN01sr..imex.util.LegacyUserDetails...........I..diagnosticStatusJ..loginTimestampL..encodingq.~..L..entityq.~..L..hostAddressq.~..L..terminalIDq.~..L..userIdq.~..L..userPasswordq.~..xp........fb..pt..001t..10.4.239.163t..K003t..MADHAVIKt..$$
Stream flushed.
Stream closed.
content-length=414
######Response Header Fields {Transfer-Encoding=[chunked], null=[HTTP/1.1 200 OK], Server=[JBoss-EAP/7], X-Content-Type-Options=[NOSNIFF], Connection=[keep-alive], Date=[Thu, 04 Aug 2022 01:15:38 GMT], Referrer-Policy=[no-referrer], X-Frame-Options=[DENY], Strict-Transport-Security=[max-age=31536000; includeSubDomains], Content-Security-Policy=[default-src 'self'], X-XSS-Protection=[1; mode=block], Content-Type=[application/octet-stream], X-Powered-By=[Undertow/1]}
######Respose ContentType application/octet-stream
######Respose going to read Object from stream...
######Respose going to close InputStream...
######Respose InputStream closed.
----------------------------------------------------
====> here is another case of valid result with the same endpoint that failed in the other case :
######Connection URL https://imexuat3-o1.sp.uat.dbs.corp:7743/imexuat3_o1/ImexServlet?SDGW
######Request Payload content Stream created.
....t..getDataEntryByKeyur..[Ljava.lang.Object;..X..s)l...xp....t..001t..AP532t..670t..Bt..MADHAVIKsr..java.lang.Integer.......8...I..valuexr..java.lang.Number...........xp....
Stream flushed.
Stream closed.
content-length=176
######Response Header Fields {Transfer-Encoding=[chunked], null=[HTTP/1.1 200 OK], Server=[JBoss-EAP/7], X-Content-Type-Options=[NOSNIFF], Connection=[keep-alive], Date=[Thu, 04 Aug 2022 01:15:38 GMT], Referrer-Policy=[no-referrer], X-Frame-Options=[DENY], Strict-Transport-Security=[max-age=31536000; includeSubDomains], Content-Security-Policy=[default-src 'self'], X-XSS-Protection=[1; mode=block], Content-Type=[application/octet-stream], X-Powered-By=[Undertow/1]}
######Respose ContentType application/octet-stream
######Respose going to read Object from stream...
######Respose going to close InputStream...
######Respose InputStream closed.
----------------------------------------------------
ACTUAL -
----------------------------------------------------
====> here is a case of failure after 30 second of hanging:
######Connection URL https://imexuat3-o1.sp.uat.dbs.corp:7743/imexuat3_o1/ImexServlet?SDGW
######Request Payload content Stream created.
....t..getDataEntryByKeyur..[Ljava.lang.Object;..X..s)l...xp....t..001t..AP532t..469t..Bt..MADHAVIKsr..java.lang.Integer.......8...I..valuexr..java.lang.Number...........xp....
Stream flushed.
Stream closed.
content-length=176
######Response Header Fields {}
######Respose Throwable Unexpected end of file from server
java.net.SocketException: Unexpected end of file from server
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection$10.run(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection$10.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.net.www.protocol.http.HttpURLConnection.getChainedException(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.access$200(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection$9.run(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection$9.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessController.doPrivilegedWithCombiner(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(Unknown Source)
at imex.client.framework.MainWindow.servletToObject(MainWindow.java:2443)
at imex.client.framework.MainWindow.objectArrayToServlet(MainWindow.java:2074)
at imex.client.framework.SDGWConnector.executeServlet(SDGWConnector.java:166)
at imex.client.framework.SDGWConnector.executeSdgwService(SDGWConnector.java:134)
at imex.client.framework.DBController.execute(DBController.java:506)
at imex.client.framework.DBController.getDataEntryByKey(DBController.java:1801)
at imex.client.framework.DBController.getDataEntryByKey(DBController.java:1774)
at imex.client.framework.DBController.getDataEntryByKey(DBController.java:1763)
at imex.client.framework.DBController.getFirstCharFromTableEntry(DBController.java:7244)
at imex.client.framework.MainWindow.setDisplayMessageOnPanel(MainWindow.java:2627)
at imex.client.framework.ClientController.init(ClientController.java:1183)
at imex.client.framework.SessionController.startMenuCommand(SessionController.java:830)
at imex.client.framework.menu.MenuController.menuAction(MenuController.java:324)
at imex.client.framework.menu.ImexMenuSkin.actionPerformed(ImexMenuSkin.java:50)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.AbstractButton.doClick(Unknown Source)
at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)
at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.net.SocketException: Unexpected end of file from server
at sun.net.www.http.HttpClient.parseHTTPHeader(Unknown Source)
at sun.net.www.http.HttpClient.parseHTTP(Unknown Source)
at sun.net.www.http.HttpClient.parseHTTPHeader(Unknown Source)
at sun.net.www.http.HttpClient.parseHTTP(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.access$200(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection$9.run(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection$9.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessController.doPrivilegedWithCombiner(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getHeaderFields(Unknown Source)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getHeaderFields(Unknown Source)
at imex.client.framework.MainWindow.objectArrayToServlet(MainWindow.java:2065)
... 50 more
----------------------------------------------------
---------- BEGIN SOURCE ----------
=====================================
File #1:
package imex.network.tester;
import java.io.EOFException;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.io.StreamCorruptedException;
import java.net.URL;
import java.net.URLConnection;
class Monitoring {
private enum ServletName{LP, SDGW};
private static final boolean TRACE_OUTPUT_PAYLOAD = true;
private String servletHost;
public Monitoring(String servletHost) {
this.servletHost = servletHost;
}
/*
some housekeeping handling
*/
private void logger(String msg){
System.out.println("######" + msg);
}
public boolean monitor() {
Object result1 = null;
try {
result1 = (String) objectArrayToServlet("getDescByCode", new Object[]{"001", "AP008", "USD",(String) null}, ServletName.SDGW);
} catch (Throwable e1) {
e1.printStackTrace();
}
Object result2 = null;
try {
result2 = (Integer) objectArrayToServlet("getFieldLength", new Object[]{"H-WINSET-ID"}, ServletName.LP);
} catch (Throwable e1) {
e1.printStackTrace();
}
return result1 != null && result2 != null;
}
private Object objectArrayToServlet(String methodName, Object[] objectArray, ServletName servletType) throws Throwable
{
URLConnection servletConnection = null;
switch(servletType) {
case SDGW:
{
URL sdgwURL = new URL(servletHost + "ImexHTTPServlet?SDGW");
servletConnection = sdgwURL.openConnection();
break;
}
case LP:
{
URL lpURL = new URL(servletHost + "ImexHTTPServlet?LP");
servletConnection = lpURL.openConnection();
break;
}
}
return objectArrayToServletImpl(servletConnection, methodName, objectArray, servletType);
}
/*
here start the actual HTTP handling
*/
private Object objectArrayToServletImpl(URLConnection servletConnection, String methodName, Object[] objectArray, ServletName servletType) throws Throwable
{
logger("Connection URL " + servletConnection.getURL());
ObjectOutputStream outputToServlet = null;
// properties setting needed to be able to send binary
servletConnection.setDoInput(true);
servletConnection.setDoOutput(true);
servletConnection.setUseCaches(false);
servletConnection.setRequestProperty("Content-Type", "application/octet-stream");
// creating the outputstream to be able to send out parameters
OutputStream out = servletConnection.getOutputStream();
// use decorator Stream in order to log the actual output
if (TRACE_OUTPUT_PAYLOAD) out = new TraceOutputStream(out);
outputToServlet = new ObjectOutputStream(out);
outputToServlet.writeObject(methodName);
outputToServlet.writeObject(objectArray);
if(servletType == ServletName.SDGW) {
outputToServlet.writeObject("NetTest");
outputToServlet.writeObject(Integer.valueOf(3));
}
outputToServlet.flush();
//closing the stream
outputToServlet.close();
if (TRACE_OUTPUT_PAYLOAD) logger("Request Payload content " + ((TraceOutputStream)out).getTrace());
logger("Response Header Fields " + servletConnection.getHeaderFields());
// calling the serletToObject method that get from the servlet an object and return it to this method
// returning the object to the method that called it
return servletToObject(servletConnection,servletType);
}
private Object servletToObject(URLConnection servletConnection, ServletName servletType) throws Throwable
{
Object b = null;
//reading the object should nothing be returned we will fall on EOF
try {
InputStream is = servletConnection.getInputStream();
String contentType = servletConnection.getContentType();
logger("Respose ContentType " + contentType);
ObjectInputStream inputFromServlet = new ObjectInputStream(is);
logger("Respose going to read Object from stream...");
b = inputFromServlet.readObject();
// closing the stream
logger("Respose going to close InputStream...");
inputFromServlet.close();
logger("Respose InputStream closed.");
}
catch (StreamCorruptedException e){
logger("Respose StreamCorruptedException " + e.getMessage());
throw e;
}
catch (EOFException e){
logger("Respose EOFException " + e.getMessage());
throw e;
}
//checking if an Exception was send from the servlet
if (b instanceof Throwable){
logger("servletToObject Throwable " + ((Throwable)b).getMessage());
throw (Throwable)b;
}
//returning the Object
return b;
}
}
=====================================
File #2:
package imex.network.tester;
import java.io.IOException;
import java.io.OutputStream;
class TraceOutputStream extends OutputStream {
private final StringBuilder buff;
private final OutputStream out;
private int len = 0;
private boolean closed = false;
private boolean flushed = false;
public TraceOutputStream(OutputStream out) {
this.out = out;
buff = new StringBuilder();
buff.append("Stream created.\n");
}
@Override
public void write(int b) throws IOException {
out.write(b);
len++;
if (b < 32){
b = '.';
}
buff.append((char)b);
}
@Override
public void flush() throws IOException {
out.flush();
if (! flushed){
buff.append("\nStream flushed.");
flushed = true;
}
}
@Override
public void close() throws IOException {
out.close();
if (! closed){
buff.append("\nStream closed.");
closed = true;
}
}
String getTrace(){
return buff.toString() + "\ncontent-length=" + len;
}
}
=====================================
File #3:
package imex.network.tester;
import java.applet.Applet;
import java.awt.Dimension;
import javax.swing.JLabel;
import javax.swing.JButton;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class MainWindow extends Applet {
@Override
public void init() {
this.setSize(new Dimension(400, 100));
this.setLayout(null);
final JLabel lbl = new JLabel("");
lbl.setBounds(new Rectangle(20, 44, 400, 20));
this.add(lbl, null);
final JButton btn = new JButton("Start");
btn.setBounds(new Rectangle(20, 14, 70, 24));
final String codeBase = getCodeBase().toString();
lbl.setText("CodeBase: " + codeBase);
btn.addActionListener(new ActionListener() {
@Override public void actionPerformed(ActionEvent e) {
boolean resutl = new Monitoring(codeBase).monitor();
lbl.setText("Result => " + resutl);
}
});
this.add(btn, null);
}
}
=====================================
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
turn off the Proxy mode (which is unacceptable by our Network and Security teams)
FREQUENCY : occasionally