HHH-12118 Removing handling of old JVM_HAS_TIMESTAMP_BUG

This commit is contained in:
Sanne Grinovero 2017-11-17 12:37:23 +01:00 committed by Steve Ebersole
parent 29d5b41700
commit 65e44267d6
5 changed files with 3 additions and 56 deletions

View File

@ -8,7 +8,6 @@
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.sql.Timestamp;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Properties; import java.util.Properties;
@ -156,7 +155,6 @@ public final class Environment implements AvailableSettings {
private static final BytecodeProvider BYTECODE_PROVIDER_INSTANCE; private static final BytecodeProvider BYTECODE_PROVIDER_INSTANCE;
private static final boolean ENABLE_BINARY_STREAMS; private static final boolean ENABLE_BINARY_STREAMS;
private static final boolean ENABLE_REFLECTION_OPTIMIZER; private static final boolean ENABLE_REFLECTION_OPTIMIZER;
private static final boolean JVM_HAS_TIMESTAMP_BUG;
private static final Properties GLOBAL_PROPERTIES; private static final Properties GLOBAL_PROPERTIES;
@ -238,31 +236,12 @@ public static void verifyProperties(Map<?,?> configurationValues) {
} }
BYTECODE_PROVIDER_INSTANCE = buildBytecodeProvider( GLOBAL_PROPERTIES ); BYTECODE_PROVIDER_INSTANCE = buildBytecodeProvider( GLOBAL_PROPERTIES );
long x = 123456789;
JVM_HAS_TIMESTAMP_BUG = new Timestamp(x).getTime() != x;
if ( JVM_HAS_TIMESTAMP_BUG ) {
LOG.usingTimestampWorkaround();
}
} }
public static BytecodeProvider getBytecodeProvider() { public static BytecodeProvider getBytecodeProvider() {
return BYTECODE_PROVIDER_INSTANCE; return BYTECODE_PROVIDER_INSTANCE;
} }
/**
* Does this JVM's implementation of {@link java.sql.Timestamp} have a bug in which the following is true:<code>
* new java.sql.Timestamp( x ).getTime() != x
* </code>
* <p/>
* NOTE : IBM JDK 1.3.1 the only known JVM to exhibit this behavior.
*
* @return True if the JVM's {@link Timestamp} implementa
*/
public static boolean jvmHasTimestampBug() {
return JVM_HAS_TIMESTAMP_BUG;
}
/** /**
* Should we use streams to bind binary types to JDBC IN parameters? * Should we use streams to bind binary types to JDBC IN parameters?
* *

View File

@ -1433,10 +1433,6 @@ void usingDefaultIdGeneratorSegmentValue(
@Message(value = "Using java.io streams to persist binary types", id = 407) @Message(value = "Using java.io streams to persist binary types", id = 407)
void usingStreams(); void usingStreams();
@LogMessage(level = INFO)
@Message(value = "Using workaround for JVM bug in java.sql.Timestamp", id = 408)
void usingTimestampWorkaround();
@LogMessage(level = WARN) @LogMessage(level = WARN)
@Message(value = "Using %s which does not generate IETF RFC 4122 compliant UUID values; consider using %s instead", @Message(value = "Using %s which does not generate IETF RFC 4122 compliant UUID values; consider using %s instead",
id = 409) id = 409)

View File

@ -11,7 +11,6 @@
import java.util.Date; import java.util.Date;
import java.util.GregorianCalendar; import java.util.GregorianCalendar;
import org.hibernate.cfg.Environment;
import org.hibernate.internal.util.compare.CalendarComparator; import org.hibernate.internal.util.compare.CalendarComparator;
import org.hibernate.type.descriptor.WrapperOptions; import org.hibernate.type.descriptor.WrapperOptions;
@ -101,16 +100,7 @@ public <X> Calendar wrap(X value, WrapperOptions options) {
} }
Calendar cal = new GregorianCalendar(); Calendar cal = new GregorianCalendar();
if ( Environment.jvmHasTimestampBug() ) { cal.setTime( (Date) value );
final long milliseconds = ( (Date) value ).getTime();
final long nanoseconds = java.sql.Timestamp.class.isInstance( value )
? ( (java.sql.Timestamp) value ).getNanos()
: 0;
cal.setTime( new Date( milliseconds + nanoseconds / 1000000 ) );
}
else {
cal.setTime( (Date) value );
}
return cal; return cal;
} }
} }

View File

@ -101,16 +101,7 @@ public <X> Calendar wrap(X value, WrapperOptions options) {
} }
Calendar cal = new GregorianCalendar(); Calendar cal = new GregorianCalendar();
if ( Environment.jvmHasTimestampBug() ) { cal.setTime( (Date) value );
final long milliseconds = ( (Date) value ).getTime();
final long nanoseconds = java.sql.Timestamp.class.isInstance( value )
? ( (java.sql.Timestamp) value ).getNanos()
: 0;
cal.setTime( new Date( milliseconds + nanoseconds / 1000000 ) );
}
else {
cal.setTime( (Date) value );
}
return cal; return cal;
} }
} }

View File

@ -117,16 +117,7 @@ public <X> Calendar wrap(X value, WrapperOptions options) {
} }
Calendar cal = new GregorianCalendar(); Calendar cal = new GregorianCalendar();
if ( Environment.jvmHasTimestampBug() ) { cal.setTime( (java.util.Date) value );
final long milliseconds = ( (java.util.Date) value ).getTime();
final long nanoseconds = java.sql.Timestamp.class.isInstance( value )
? ( (java.sql.Timestamp) value ).getNanos()
: 0;
cal.setTime( new Date( milliseconds + nanoseconds / 1000000 ) );
}
else {
cal.setTime( (java.util.Date) value );
}
return cal; return cal;
} }
} }