Skip to content

Commit 01084cb

Browse files
committed
compare enums with ==, avoid chances of NPE
1 parent 6fc37dc commit 01084cb

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

hystrix-contrib/hystrix-metrics-event-stream/src/main/java/com/netflix/hystrix/contrib/requests/stream/HystrixRequestEventsJsonStream.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ private static void convertExecutionToJson(JsonGenerator json, HystrixRequestEve
7575
json.writeArrayFieldStart("events");
7676
ExecutionResult.EventCounts eventCounts = executionSignature.getEventCounts();
7777
for (HystrixEventType eventType: HystrixEventType.values()) {
78-
if (!eventType.equals(HystrixEventType.COLLAPSED)) {
78+
if (eventType != HystrixEventType.COLLAPSED) {
7979
if (eventCounts.contains(eventType)) {
8080
int eventCount = eventCounts.getCount(eventType);
8181
if (eventCount > 1) {

hystrix-core/src/main/java/com/netflix/hystrix/AbstractCommand.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ public void call(Notification<? super R> rNotification) {
609609
}
610610

611611
private Observable<R> executeCommandWithSpecifiedIsolation(final AbstractCommand<R> _cmd) {
612-
if (properties.executionIsolationStrategy().get().equals(ExecutionIsolationStrategy.THREAD)) {
612+
if (properties.executionIsolationStrategy().get() == ExecutionIsolationStrategy.THREAD) {
613613
// mark that we are executing in a thread (even if we end up being rejected we still were a THREAD execution and not SEMAPHORE)
614614
return Observable.defer(new Func0<Observable<R>>() {
615615
@Override
@@ -674,7 +674,7 @@ public void call() {
674674
}).subscribeOn(threadPool.getScheduler(new Func0<Boolean>() {
675675
@Override
676676
public Boolean call() {
677-
return properties.executionIsolationThreadInterruptOnTimeout().get() && _cmd.isCommandTimedOut.get().equals(TimedOutStatus.TIMED_OUT);
677+
return properties.executionIsolationThreadInterruptOnTimeout().get() && _cmd.isCommandTimedOut.get() == TimedOutStatus.TIMED_OUT;
678678
}
679679
}));
680680
} else {
@@ -1209,7 +1209,7 @@ protected TryableSemaphore getFallbackSemaphore() {
12091209
* @return TryableSemaphore
12101210
*/
12111211
protected TryableSemaphore getExecutionSemaphore() {
1212-
if (properties.executionIsolationStrategy().get().equals(ExecutionIsolationStrategy.SEMAPHORE)) {
1212+
if (properties.executionIsolationStrategy().get() == ExecutionIsolationStrategy.SEMAPHORE) {
12131213
if (executionSemaphoreOverride == null) {
12141214
TryableSemaphore _s = executionSemaphorePerCircuit.get(commandKey.name());
12151215
if (_s == null) {
@@ -1719,7 +1719,7 @@ public boolean isCircuitBreakerOpen() {
17191719
* @return boolean
17201720
*/
17211721
public boolean isExecutionComplete() {
1722-
return commandState.get().equals(CommandState.TERMINAL);
1722+
return commandState.get() == CommandState.TERMINAL;
17231723
}
17241724

17251725
/**

hystrix-core/src/main/java/com/netflix/hystrix/metric/HystrixCommandExecutionStarted.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public boolean isExecutionStart() {
4141

4242
@Override
4343
public boolean isExecutedInThread() {
44-
return isolationStrategy.equals(HystrixCommandProperties.ExecutionIsolationStrategy.THREAD);
44+
return isolationStrategy == HystrixCommandProperties.ExecutionIsolationStrategy.THREAD;
4545
}
4646

4747
@Override

0 commit comments

Comments
 (0)