diff --git a/plugins/org.eclipse.tm.terminal.connector.telnet/src/org/eclipse/tm/terminal/connector/telnet/connector/TelnetConnection.java b/plugins/org.eclipse.tm.terminal.connector.telnet/src/org/eclipse/tm/terminal/connector/telnet/connector/TelnetConnection.java
index 93a24906275..fdc23785705 100644
--- a/plugins/org.eclipse.tm.terminal.connector.telnet/src/org/eclipse/tm/terminal/connector/telnet/connector/TelnetConnection.java
+++ b/plugins/org.eclipse.tm.terminal.connector.telnet/src/org/eclipse/tm/terminal/connector/telnet/connector/TelnetConnection.java
@@ -270,7 +270,7 @@ public class TelnetConnection extends Thread implements TelnetCodes {
height = newHeight;
if (sizeChanged && remoteIsTelnetServer && localOptions[TELNET_OPTION_NAWS].isEnabled()) {
- Integer[] sizeData = { new Integer(width), new Integer(height) };
+ Integer[] sizeData = { Integer.valueOf(width), Integer.valueOf(height) };
localOptions[TELNET_OPTION_NAWS].sendSubnegotiation(sizeData);
}
@@ -418,6 +418,7 @@ public class TelnetConnection extends Thread implements TelnetCodes {
// TELNET protocol data.
byte inputByte = rawBytes[byteIndex];
+ int ubyte = inputByte & 0xFF;
switch (telnetState) {
case STATE_INITIAL:
@@ -427,7 +428,7 @@ public class TelnetConnection extends Thread implements TelnetCodes {
// It's not an IAC code, so just append it to
// processedBytes.
- processedBytes[nextProcessedByte++] = rawBytes[byteIndex];
+ processedBytes[nextProcessedByte++] = inputByte;
}
break;
@@ -489,7 +490,7 @@ public class TelnetConnection extends Thread implements TelnetCodes {
default:
// Unrecognized command! This should never happen.
Logger.log("processTelnetProtocol: UNRECOGNIZED TELNET PROTOCOL COMMAND: " + //$NON-NLS-1$
- inputByte);
+ ubyte);
telnetState = STATE_INITIAL;
break;
}
@@ -500,36 +501,36 @@ public class TelnetConnection extends Thread implements TelnetCodes {
// local options.
case STATE_WILL_RECEIVED:
- Logger.log("Received WILL " + localOptions[inputByte].optionName() + "."); //$NON-NLS-1$ //$NON-NLS-2$
- remoteOptions[inputByte].handleWill();
+ Logger.log("Received WILL " + localOptions[ubyte].optionName() + "."); //$NON-NLS-1$ //$NON-NLS-2$
+ remoteOptions[ubyte].handleWill();
telnetState = STATE_INITIAL;
telnetServerDetected();
break;
case STATE_WONT_RECEIVED:
- Logger.log("Received WONT " + localOptions[inputByte].optionName() + "."); //$NON-NLS-1$ //$NON-NLS-2$
- remoteOptions[inputByte].handleWont();
+ Logger.log("Received WONT " + localOptions[ubyte].optionName() + "."); //$NON-NLS-1$ //$NON-NLS-2$
+ remoteOptions[ubyte].handleWont();
telnetState = STATE_INITIAL;
telnetServerDetected();
break;
case STATE_DO_RECEIVED:
- Logger.log("Received DO " + localOptions[inputByte].optionName() + "."); //$NON-NLS-1$ //$NON-NLS-2$
- localOptions[inputByte].handleDo();
+ Logger.log("Received DO " + localOptions[ubyte].optionName() + "."); //$NON-NLS-1$ //$NON-NLS-2$
+ localOptions[ubyte].handleDo();
telnetState = STATE_INITIAL;
telnetServerDetected();
break;
case STATE_DONT_RECEIVED:
- Logger.log("Received DONT " + localOptions[inputByte].optionName() + "."); //$NON-NLS-1$ //$NON-NLS-2$
- localOptions[inputByte].handleDont();
+ Logger.log("Received DONT " + localOptions[ubyte].optionName() + "."); //$NON-NLS-1$ //$NON-NLS-2$
+ localOptions[ubyte].handleDont();
telnetState = STATE_INITIAL;
telnetServerDetected();
break;
case STATE_SUBNEGOTIATION_STARTED:
Logger.log("Starting subnegotiation for option " + //$NON-NLS-1$
- localOptions[inputByte].optionName() + "."); //$NON-NLS-1$
+ localOptions[ubyte].optionName() + "."); //$NON-NLS-1$
// First, zero out the array of received subnegotiation butes.
@@ -608,7 +609,7 @@ public class TelnetConnection extends Thread implements TelnetCodes {
receivedSubnegotiation[nextSubnegotiationByteIndex - 1] = 0;
- int subnegotiatedOption = receivedSubnegotiation[0];
+ int subnegotiatedOption = receivedSubnegotiation[0] & 0xFF;
localOptions[subnegotiatedOption].handleSubnegotiation(receivedSubnegotiation,
nextSubnegotiationByteIndex);
@@ -636,7 +637,7 @@ public class TelnetConnection extends Thread implements TelnetCodes {
Logger.log("SUBNEGOTIATION BUFFER FULL!"); //$NON-NLS-1$
ignoreSubnegotiation = true;
} else {
- Logger.log("Recording subnegotiation byte " + (inputByte & 0xff)); //$NON-NLS-1$
+ Logger.log("Recording subnegotiation byte " + ubyte); //$NON-NLS-1$
receivedSubnegotiation[nextSubnegotiationByteIndex++] = inputByte;
}
diff --git a/plugins/org.eclipse.tm.terminal.connector.telnet/src/org/eclipse/tm/terminal/connector/telnet/connector/TelnetOption.java b/plugins/org.eclipse.tm.terminal.connector.telnet/src/org/eclipse/tm/terminal/connector/telnet/connector/TelnetOption.java
index c1d781f580a..9aae825a40b 100644
--- a/plugins/org.eclipse.tm.terminal.connector.telnet/src/org/eclipse/tm/terminal/connector/telnet/connector/TelnetOption.java
+++ b/plugins/org.eclipse.tm.terminal.connector.telnet/src/org/eclipse/tm/terminal/connector/telnet/connector/TelnetOption.java
@@ -262,7 +262,7 @@ class TelnetOption implements TelnetCodes
* parameter option.
*/
public String optionName() {
- return optionNames[option];
+ return optionNames[option & 0xFF];
}
/**
@@ -524,7 +524,7 @@ class TelnetOption implements TelnetCodes
break;
}
- // Tell the remote endpoint our terminal type is "ansi" using this sequence
+ // Tell the remote endpoint our terminal type is "xterm" using this sequence
// of TELNET protocol bytes:
//
// IAC SB TERMINAL-TYPE IS x t e r m IAC SE
@@ -565,7 +565,7 @@ class TelnetOption implements TelnetCodes
// IAC SB NAWS
// IAC SE
- byte[] NAWSData = { TELNET_IAC, TELNET_SB, TELNET_OPTION_NAWS, 0,
+ final byte[] NAWSData = { TELNET_IAC, TELNET_SB, TELNET_OPTION_NAWS, 0,
0, 0, 0, TELNET_IAC, TELNET_SE };
int width = ((Integer) subnegotiationData[0]).intValue();
int height = ((Integer) subnegotiationData[1]).intValue();
@@ -579,12 +579,6 @@ class TelnetOption implements TelnetCodes
.log("sending terminal size to remote endpoint: width = " + width + //$NON-NLS-1$
", height = " + height + "."); //$NON-NLS-1$ //$NON-NLS-2$
- // This final local variable is a hack to get around the fact that inner
- // classes cannot reference a non-final local variable in a lexically
- // enclosing scope.
-
- final byte[] NAWSDataFinal = NAWSData;
-
// Send the NAWS data in a new thread. The current thread is the display
// thread, and calls to write() can block, but blocking the display thread
// is _bad_ (it hangs the GUI).
@@ -593,7 +587,7 @@ class TelnetOption implements TelnetCodes
@Override
public void run() {
try {
- outputStream.write(NAWSDataFinal);
+ outputStream.write(NAWSData);
} catch (IOException ex) {
Logger.log("IOException sending NAWS subnegotiation!"); //$NON-NLS-1$
Logger.logException(ex);