Skip to content

Commit 552776c

Browse files
authored
[ECR-4395] Fix sonar bugs (#1547)
1 parent 34083c6 commit 552776c

File tree

5 files changed

+13
-8
lines changed

5 files changed

+13
-8
lines changed

exonum-java-binding/common/src/main/java/com/exonum/binding/common/hash/AbstractHasher.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public <T> Hasher putObject(T instance, Funnel<? super T> funnel) {
134134
return this;
135135
}
136136

137-
@SuppressWarnings("EmptyMethod")
137+
@SuppressWarnings({"EmptyMethod", "squid:S1206"})
138138
@Override
139139
@Deprecated
140140
public int hashCode() {

exonum-java-binding/core/src/main/java/com/exonum/binding/core/blockchain/Block.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ public final boolean isEmpty() {
107107
*/
108108
public abstract ImmutableMap<String, ByteString> getAdditionalHeaders();
109109

110+
// TODO: remove after https://jira.sonarsource.com/browse/SONARJAVA-3377
111+
@SuppressWarnings("squid:S1206")
110112
@Override
111113
public int hashCode() {
112114
// Use just the first 4 bytes of the SHA-256 hash of the binary object representation,

exonum-java-binding/core/src/main/java/com/exonum/binding/core/runtime/RuntimeTransport.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,11 @@ public RuntimeTransport(Server server, @Named(SERVICE_WEB_SERVER_PORT) int port)
5858
void start() {
5959
try {
6060
server.start(port).get();
61-
} catch (InterruptedException | ExecutionException e) {
61+
} catch (ExecutionException e) {
6262
throw new IllegalStateException(e);
63+
} catch (InterruptedException e) {
64+
logger.error("Start services API server was interrupted", e);
65+
Thread.currentThread().interrupt();
6366
}
6467
}
6568

exonum-java-binding/core/src/main/java/com/exonum/binding/core/storage/indices/RustIterAdapter.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,10 @@ public boolean hasNext() {
4646

4747
@Override
4848
public E next() {
49-
if (!hasNext()) {
50-
throw new NoSuchElementException("Reached the end of the underlying collection. "
51-
+ "Use #hasNext to check if you have reached the end of the collection.");
52-
}
53-
Optional<E> nextElement = nextItem;
49+
E element = nextItem.orElseThrow(
50+
() -> new NoSuchElementException("Reached the end of the underlying collection. "
51+
+ "Use #hasNext to check if you have reached the end of the collection."));
5452
nextItem = rustIter.next(); // an after-the-next item
55-
return nextElement.get();
53+
return element;
5654
}
5755
}

exonum-java-binding/core/src/main/java/com/exonum/binding/core/storage/indices/ValueSetIndexProxy.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,8 @@ public abstract static class Entry<E> {
250250

251251
// Do not include (potentially) large value in the hash code: we already have a SHA-256 hash.
252252
@Override
253+
// TODO: remove after https://jira.sonarsource.com/browse/SONARJAVA-3377
254+
@SuppressWarnings("squid:S1206")
253255
public final int hashCode() {
254256
// Use just the first 4 bytes of the SHA-256 hash of the binary value,
255257
// as they will have close to uniform distribution.

0 commit comments

Comments
 (0)