SAM: Cherrypick from patch in ticket #1318:

- Fix empty properties check
   - Overrides
   - Statics
This commit is contained in:
zzz
2014-06-27 20:53:01 +00:00
parent 0fc3029aaa
commit bb9129b61b
3 changed files with 19 additions and 17 deletions

View File

@@ -219,7 +219,7 @@ class SAMv1Handler extends SAMHandler implements SAMRawReceiver, SAMDatagramRece
_log.debug("Trying to create a session, but one still exists");
return writeString("SESSION STATUS RESULT=I2P_ERROR MESSAGE=\"Session already exists\"\n");
}
if (props == null) {
if (props.isEmpty()) {
if (_log.shouldLog(Log.DEBUG))
_log.debug("No parameters specified in SESSION CREATE message");
return writeString("SESSION STATUS RESULT=I2P_ERROR MESSAGE=\"No parameters for SESSION CREATE\"\n");
@@ -356,7 +356,7 @@ class SAMv1Handler extends SAMHandler implements SAMRawReceiver, SAMDatagramRece
/* Parse and execute a NAMING message */
protected boolean execNamingMessage(String opcode, Properties props) {
if (opcode.equals("LOOKUP")) {
if (props == null) {
if (props.isEmpty()) {
_log.debug("No parameters specified in NAMING LOOKUP message");
return false;
}
@@ -413,7 +413,7 @@ class SAMv1Handler extends SAMHandler implements SAMRawReceiver, SAMDatagramRece
}
if (opcode.equals("SEND")) {
if (props == null) {
if (props.isEmpty()) {
if (_log.shouldLog(Log.DEBUG))
_log.debug("No parameters specified in DATAGRAM SEND message");
return false;
@@ -493,7 +493,7 @@ class SAMv1Handler extends SAMHandler implements SAMRawReceiver, SAMDatagramRece
}
if (opcode.equals("SEND")) {
if (props == null) {
if (props.isEmpty()) {
if (_log.shouldLog(Log.DEBUG))
_log.debug("No parameters specified in RAW SEND message");
return false;
@@ -587,7 +587,7 @@ class SAMv1Handler extends SAMHandler implements SAMRawReceiver, SAMDatagramRece
}
protected boolean execStreamSend(Properties props) {
if (props == null) {
if (props.isEmpty()) {
if (_log.shouldLog(Log.DEBUG))
_log.debug("No parameters specified in STREAM SEND message");
return false;
@@ -657,7 +657,7 @@ class SAMv1Handler extends SAMHandler implements SAMRawReceiver, SAMDatagramRece
}
protected boolean execStreamConnect(Properties props) {
if (props == null) {
if (props.isEmpty()) {
if (_log.shouldLog(Log.DEBUG))
_log.debug("No parameters specified in STREAM CONNECT message");
return false;
@@ -733,7 +733,7 @@ class SAMv1Handler extends SAMHandler implements SAMRawReceiver, SAMDatagramRece
}
protected boolean execStreamClose(Properties props) {
if (props == null) {
if (props.isEmpty()) {
if (_log.shouldLog(Log.DEBUG))
_log.debug("No parameters specified in STREAM CLOSE message");
return false;

View File

@@ -69,6 +69,7 @@ class SAMv2Handler extends SAMv1Handler implements SAMRawReceiver, SAMDatagramRe
/* Parse and execute a STREAM message */
@Override
protected boolean execStreamMessage ( String opcode, Properties props )
{
if ( getStreamSession() == null )
@@ -108,7 +109,7 @@ class SAMv2Handler extends SAMv1Handler implements SAMRawReceiver, SAMDatagramRe
private boolean execStreamReceive ( Properties props )
{
if ( props == null )
if (props.isEmpty())
{
if (_log.shouldLog(Log.DEBUG))
_log.debug ( "No parameters specified in STREAM RECEIVE message" );

View File

@@ -473,7 +473,7 @@ class SAMv3Handler extends SAMv1Handler
_log.debug("Trying to create a session, but one still exists");
return writeString("SESSION STATUS RESULT=I2P_ERROR MESSAGE=\"Session already exists\"\n");
}
if (props == null) {
if (props.isEmpty()) {
if (_log.shouldLog(Log.DEBUG))
_log.debug("No parameters specified in SESSION CREATE message");
return writeString("SESSION STATUS RESULT=I2P_ERROR MESSAGE=\"No parameters for SESSION CREATE\"\n");
@@ -602,25 +602,26 @@ class SAMv3Handler extends SAMv1Handler
/**
* @throws NPE if login nickname is not registered
*/
private SAMv3StreamSession newSAMStreamSession(String login )
throws IOException, DataFormatException, SAMException
private static SAMv3StreamSession newSAMStreamSession(String login )
throws IOException, DataFormatException, SAMException
{
return new SAMv3StreamSession( login ) ;
}
private SAMv3RawSession newSAMRawSession(String login )
throws IOException, DataFormatException, SAMException, I2PSessionException
private static SAMv3RawSession newSAMRawSession(String login )
throws IOException, DataFormatException, SAMException, I2PSessionException
{
return new SAMv3RawSession( login ) ;
}
private SAMv3DatagramSession newSAMDatagramSession(String login )
throws IOException, DataFormatException, SAMException, I2PSessionException
private static SAMv3DatagramSession newSAMDatagramSession(String login )
throws IOException, DataFormatException, SAMException, I2PSessionException
{
return new SAMv3DatagramSession( login ) ;
}
/* Parse and execute a STREAM message */
@Override
protected boolean execStreamMessage ( String opcode, Properties props )
{
String nick = null ;
@@ -693,10 +694,10 @@ class SAMv3Handler extends SAMv1Handler
}
}
@Override
protected boolean execStreamConnect( Properties props) {
try {
if (props == null) {
if (props.isEmpty()) {
notifyStreamResult(true,"I2P_ERROR","No parameters specified in STREAM CONNECT message");
if (_log.shouldLog(Log.DEBUG))
_log.debug("No parameters specified in STREAM CONNECT message");