Prepare 2.5.0 release (Java 8 only)

pull/705/head
Brett Wooldridge 9 years ago
parent 03122e85b4
commit cce7c9133d

@ -10,6 +10,4 @@ install: /bin/true
script: script:
- mvn install -Dskip.unit.tests=true -Dmaven.javadoc.skip=true -V -B - mvn install -Dskip.unit.tests=true -Dmaven.javadoc.skip=true -V -B
- mvn clean test coveralls:report -V -P coverage - mvn test coveralls:report -V -P coverage
- jdk_switcher use openjdk7
- mvn test

@ -3,7 +3,7 @@
<groupId>com.zaxxer</groupId> <groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId> <artifactId>HikariCP</artifactId>
<version>2.4.8-SNAPSHOT</version> <version>2.5.0-SNAPSHOT</version>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<name>HikariCP</name> <name>HikariCP</name>

@ -16,9 +16,6 @@
package com.zaxxer.hikari.util; package com.zaxxer.hikari.util;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.LongAdder; import java.util.concurrent.atomic.LongAdder;
@ -49,22 +46,13 @@ public interface Sequence
{ {
public static Sequence create() public static Sequence create()
{ {
if (UtilityElf.isJdk8Plus() && !Boolean.getBoolean("com.zaxxer.hikari.useAtomicLongSequence")) { if (!Boolean.getBoolean("com.zaxxer.hikari.useAtomicLongSequence")) {
return new Java8Sequence(); return new Java8Sequence();
} }
else { else {
try { return new Java7Sequence();
Class<?> longAdderClass = Sequence.class.getClassLoader().loadClass("com.codahale.metrics.LongAdder");
return new DropwizardSequence(longAdderClass);
}
catch (Exception e2) {
// fall thru
}
} }
return new Java7Sequence();
} }
} }
final class Java7Sequence extends AtomicLong implements Sequence { final class Java7Sequence extends AtomicLong implements Sequence {
@ -80,42 +68,4 @@ public interface Sequence
return this.sum(); return this.sum();
} }
} }
final class DropwizardSequence implements Sequence {
private final Object longAdder;
private final Method increment;
private final Method sum;
public DropwizardSequence(Class<?> longAdderClass) throws Exception {
Constructor<?> constructor = longAdderClass.getDeclaredConstructors()[0];
constructor.setAccessible(true);
increment = longAdderClass.getMethod("increment");
increment.setAccessible(true);
sum = longAdderClass.getMethod("sum");
sum.setAccessible(true);
longAdder = constructor.newInstance();
}
@Override
public void increment()
{
try {
increment.invoke(longAdder);
}
catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
throw new RuntimeException(e);
}
}
@Override
public long get()
{
try {
return (Long) sum.invoke(longAdder);
}
catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
throw new RuntimeException(e);
}
}
}
} }

@ -26,8 +26,6 @@ import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.RejectedExecutionHandler; import java.util.concurrent.RejectedExecutionHandler;
import java.util.concurrent.ThreadFactory; import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.ThreadPoolExecutor;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/** /**
* *
@ -154,20 +152,6 @@ public final class UtilityElf
return -1; return -1;
} }
/**
* Are we running on JDK 8 or above?
*
* @return true if JDK 8+, false otherwise
*/
public static boolean isJdk8Plus() {
Matcher matcher = Pattern.compile("(?:(\\d+(?:\\.?\\d*)))").matcher(System.getProperty("java.version"));
if (!matcher.find()) {
return false;
}
return Float.parseFloat(matcher.group(1)) > 1.7f;
}
public static final class DefaultThreadFactory implements ThreadFactory { public static final class DefaultThreadFactory implements ThreadFactory {
private final String threadName; private final String threadName;

Loading…
Cancel
Save