Skip to content

Commit

Permalink
Polishing #481
Browse files Browse the repository at this point in the history
Add author tag. Reformat code.
  • Loading branch information
mp911de committed Mar 14, 2017
1 parent 113fd3b commit 7412993
Showing 1 changed file with 8 additions and 5 deletions.
@@ -1,5 +1,5 @@
/*
* Copyright 2011-2016 the original author or authors.
* Copyright 2011-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -38,6 +38,7 @@
*
* @author Will Glozer
* @author Mark Paluch
* @author Helly Guo
*/
public class RedisStateMachine {

Expand All @@ -48,15 +49,16 @@ public class RedisStateMachine {
private static final Class LONG_PROCESSOR_CLASS;

static {

Version nettyBufferVersion = Version.identify().get("netty-buffer");

USE_NETTY40_BYTEBUF_COMPATIBILITY =
nettyBufferVersion != null && nettyBufferVersion.artifactVersion().startsWith("4.0");
USE_NETTY40_BYTEBUF_COMPATIBILITY = nettyBufferVersion != null
&& nettyBufferVersion.artifactVersion().startsWith("4.0");
if (!USE_NETTY40_BYTEBUF_COMPATIBILITY) {
try {
LONG_PROCESSOR_CLASS = Class.forName("com.lambdaworks.redis.protocol.RedisStateMachine$Netty41LongProcessor");
} catch (ClassNotFoundException e) {
throw new RedisException("Cannot create Netty41ToLongProcessor instance", e);
throw new RedisException("Cannot load Netty41LongProcessor class", e);
}
} else {
LONG_PROCESSOR_CLASS = null;
Expand Down Expand Up @@ -86,11 +88,12 @@ enum Type {
public RedisStateMachine() {

LongProcessor longProcessor;

if (!USE_NETTY40_BYTEBUF_COMPATIBILITY) {
try {
longProcessor = (LongProcessor) LONG_PROCESSOR_CLASS.newInstance();
} catch (ReflectiveOperationException e) {
throw new RedisException("Cannot create Netty41ToLongProcessor instance", e);
throw new RedisException("Cannot create Netty41LongProcessor instance", e);
}
} else {
longProcessor = new LongProcessor();
Expand Down

0 comments on commit 7412993

Please sign in to comment.