Updated Branches:
refs/heads/trunk 1e06041f2 -> aa89af17b
Added some missing { and } in if stmts
Project: http://git-wip-us.apache.org/repos/asf/mina/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina/commit/976e1518
Tree: http://git-wip-us.apache.org/repos/asf/mina/tree/976e1518
Diff: http://git-wip-us.apache.org/repos/asf/mina/diff/976e1518
Branch: refs/heads/trunk
Commit: 976e151834e420f9f70b764c70babbf747ce3cac
Parents: 1e06041
Author: Emmanuel Lécharny <[email protected]>
Authored: Sun May 12 00:37:33 2013 +0200
Committer: Emmanuel Lécharny <[email protected]>
Committed: Sun May 12 00:37:33 2013 +0200
----------------------------------------------------------------------
.../java/org/apache/mina/coap/CoapMessage.java | 43 +++++++++++----
.../main/java/org/apache/mina/coap/CoapOption.java | 21 ++++++--
.../apache/mina/codec/delimited/ints/VarInt.java | 18 ++++---
.../org/apache/mina/util/AbstractIoFuture.java | 17 +++++-
4 files changed, 74 insertions(+), 25 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mina/blob/976e1518/coap/src/main/java/org/apache/mina/coap/CoapMessage.java
----------------------------------------------------------------------
diff --git a/coap/src/main/java/org/apache/mina/coap/CoapMessage.java
b/coap/src/main/java/org/apache/mina/coap/CoapMessage.java
index ff278fc..179244f 100644
--- a/coap/src/main/java/org/apache/mina/coap/CoapMessage.java
+++ b/coap/src/main/java/org/apache/mina/coap/CoapMessage.java
@@ -110,6 +110,7 @@ public class CoapMessage {
.append(code).append(", id=").append(id).append(",
token=").append(Arrays.toString(token))
.append(",
payload=").append(Arrays.toString(payload)).append(", options=")
.append(Arrays.toString(options)).append("]");
+
return builder.toString();
}
@@ -127,6 +128,7 @@ public class CoapMessage {
result = prime * result + Arrays.hashCode(token);
result = prime * result + ((type == null) ? 0 : type.hashCode());
result = prime * result + version;
+
return result;
}
@@ -135,27 +137,48 @@ public class CoapMessage {
*/
@Override
public boolean equals(Object obj) {
- if (this == obj)
+ if (this == obj) {
return true;
- if (obj == null)
+ }
+
+ if (obj == null) {
return false;
- if (getClass() != obj.getClass())
+ }
+
+ if (getClass() != obj.getClass()) {
return false;
+ }
+
CoapMessage other = (CoapMessage) obj;
- if (code != other.code)
+
+ if (code != other.code) {
return false;
- if (id != other.id)
+ }
+
+ if (id != other.id) {
return false;
- if (!Arrays.equals(options, other.options))
+ }
+
+ if (!Arrays.equals(options, other.options)) {
return false;
- if (!Arrays.equals(payload, other.payload))
+ }
+
+ if (!Arrays.equals(payload, other.payload)) {
return false;
- if (!Arrays.equals(token, other.token))
+ }
+
+ if (!Arrays.equals(token, other.token)) {
return false;
- if (type != other.type)
+ }
+
+ if (type != other.type) {
return false;
- if (version != other.version)
+ }
+
+ if (version != other.version) {
return false;
+ }
+
return true;
}
http://git-wip-us.apache.org/repos/asf/mina/blob/976e1518/coap/src/main/java/org/apache/mina/coap/CoapOption.java
----------------------------------------------------------------------
diff --git a/coap/src/main/java/org/apache/mina/coap/CoapOption.java
b/coap/src/main/java/org/apache/mina/coap/CoapOption.java
index a2efa82..1bfadde 100644
--- a/coap/src/main/java/org/apache/mina/coap/CoapOption.java
+++ b/coap/src/main/java/org/apache/mina/coap/CoapOption.java
@@ -78,17 +78,28 @@ public class CoapOption {
*/
@Override
public boolean equals(Object obj) {
- if (this == obj)
+ if (this == obj) {
return true;
- if (obj == null)
+ }
+
+ if (obj == null) {
return false;
- if (getClass() != obj.getClass())
+ }
+
+ if (getClass() != obj.getClass()) {
return false;
+ }
+
CoapOption other = (CoapOption) obj;
- if (!Arrays.equals(data, other.data))
+
+ if (!Arrays.equals(data, other.data)) {
return false;
- if (type != other.type)
+ }
+
+ if (type != other.type) {
return false;
+ }
+
return true;
}
}
http://git-wip-us.apache.org/repos/asf/mina/blob/976e1518/codec/src/main/java/org/apache/mina/codec/delimited/ints/VarInt.java
----------------------------------------------------------------------
diff --git
a/codec/src/main/java/org/apache/mina/codec/delimited/ints/VarInt.java
b/codec/src/main/java/org/apache/mina/codec/delimited/ints/VarInt.java
index 33d100b..46fe5cb 100644
--- a/codec/src/main/java/org/apache/mina/codec/delimited/ints/VarInt.java
+++ b/codec/src/main/java/org/apache/mina/codec/delimited/ints/VarInt.java
@@ -102,16 +102,18 @@ public class VarInt {
for (int i = 0;; i += 7) {
byte tmp = input.get();
- if ((tmp & 0x80) == 0 && (i != 4 * 7 || tmp < 1 << 3))
+ if ((tmp & 0x80) == 0 && (i != 4 * 7 || tmp < 1 << 3)) {
return size | (tmp << i);
- else if (i < 4 * 7)
+ } else if (i < 4 * 7) {
size |= (tmp & 0x7f) << i;
- else
+ } else {
throw new ProtocolDecoderException("Not the varint
representation of a signed int32");
+ }
}
} catch (BufferUnderflowException bue) {
input.position(origpos);
}
+
return null;
}
}
@@ -127,8 +129,10 @@ public class VarInt {
@Override
public void writeTo(Integer message, ByteBuffer buffer) {
// VarInts don't support negative values
- if (message < 0)
+ if (message < 0) {
message = 0;
+ }
+
int value = message;
while (value > 0x7f) {
@@ -136,14 +140,14 @@ public class VarInt {
value >>= 7;
}
- buffer.put((byte) value);
+ buffer.put((byte) value);
}
@Override
public int getEncodedSize(Integer message) {
- if (message < 1)
+ if (message < 1) {
return 1;
- else {
+ } else {
int log2 = 32 - Integer.numberOfLeadingZeros(message);
return (log2 + 6) / 7;
}
http://git-wip-us.apache.org/repos/asf/mina/blob/976e1518/core/src/main/java/org/apache/mina/util/AbstractIoFuture.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/mina/util/AbstractIoFuture.java
b/core/src/main/java/org/apache/mina/util/AbstractIoFuture.java
index 1ba2f71..2bb32d1 100644
--- a/core/src/main/java/org/apache/mina/util/AbstractIoFuture.java
+++ b/core/src/main/java/org/apache/mina/util/AbstractIoFuture.java
@@ -75,6 +75,7 @@ public abstract class AbstractIoFuture<V> implements
IoFuture<V> {
if (listener != null) {
LOG.debug("future is done calling listener");
Object object = result.get();
+
if (object instanceof Throwable) {
scheduleException(listener, (Throwable) object);
} else {
@@ -103,6 +104,7 @@ public abstract class AbstractIoFuture<V> implements
IoFuture<V> {
} else {
LOG.debug("Unable to cancel");
}
+
latch.countDown();
}
@@ -141,10 +143,12 @@ public abstract class AbstractIoFuture<V> implements
IoFuture<V> {
latch.await();
LOG.trace("Wait completed");
- if (isCancelled())
+ if (isCancelled()) {
throw new CancellationException();
+ }
Object object = result.get();
+
if (object instanceof ExecutionException) {
throw (ExecutionException) object;
} else {
@@ -159,14 +163,19 @@ public abstract class AbstractIoFuture<V> implements
IoFuture<V> {
public V get(long timeout, TimeUnit unit) throws InterruptedException,
ExecutionException, TimeoutException {
LOG.trace("Entering wait");
- if (!latch.await(timeout, unit))
+
+ if (!latch.await(timeout, unit)) {
throw new TimeoutException();
+ }
+
LOG.trace("Wait completed");
- if (isCancelled())
+ if (isCancelled()) {
throw new CancellationException();
+ }
Object object = result.get();
+
if (object instanceof ExecutionException) {
throw (ExecutionException) object;
} else {
@@ -209,6 +218,7 @@ public abstract class AbstractIoFuture<V> implements
IoFuture<V> {
*/
protected void scheduleResult(IoFutureListener<V> listener, V result) {
LOG.debug("Calling the default result scheduler");
+
try {
listener.completed(result);
} catch (Throwable t) {
@@ -226,6 +236,7 @@ public abstract class AbstractIoFuture<V> implements
IoFuture<V> {
*/
protected void scheduleException(IoFutureListener<V> listener, Throwable
throwable) {
LOG.debug("Calling the default exception scheduler");
+
try {
listener.exception(throwable);
} catch (Throwable t) {