Skip to content

Commit

Permalink
forced the utf8 encoding for storage configuration on the network, re…
Browse files Browse the repository at this point in the history
…moved version upgrade
  • Loading branch information
tglman committed Apr 12, 2017
1 parent e0bd637 commit 17f0b0f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 36 deletions.
Expand Up @@ -389,10 +389,10 @@ public void open(final String iUserName, final String iUserPassword, final OCont
if (strategy != null)
connectionStrategy = CONNECTION_STRATEGY.valueOf(strategy.toUpperCase());

final int serverVersion = openRemoteDatabase();
openRemoteDatabase();

final OStorageConfiguration storageConfiguration = new OStorageRemoteConfiguration(this,
ORecordSerializerFactory.instance().getDefaultRecordSerializer().toString(), serverVersion);
ORecordSerializerFactory.instance().getDefaultRecordSerializer().toString());
storageConfiguration.load(conf);

configuration = storageConfiguration;
Expand Down Expand Up @@ -1249,9 +1249,9 @@ protected String reopenRemoteDatabase() throws IOException {
}
}

protected synchronized int openRemoteDatabase() throws IOException {
protected synchronized void openRemoteDatabase() throws IOException {
final String currentURL = getNextAvailableServerURL(true, getCurrentSession());
return openRemoteDatabase(currentURL);
openRemoteDatabase(currentURL);
}

public void openRemoteDatabase(OChannelBinaryAsynchClient network) throws IOException {
Expand Down Expand Up @@ -1299,16 +1299,15 @@ public void openRemoteDatabase(OChannelBinaryAsynchClient network) throws IOExce
}
}

protected int openRemoteDatabase(String currentURL) {
protected void openRemoteDatabase(String currentURL) {
do {
do {
OChannelBinaryAsynchClient network = null;
try {
network = getNetwork(currentURL);
final int serverVersion = network.getSrvProtocolVersion();
openRemoteDatabase(network);

return serverVersion;
return;
} catch (OIOException e) {
if (network != null) {
// REMOVE THE NETWORK CONNECTION IF ANY
Expand Down
Expand Up @@ -29,22 +29,12 @@ public class OStorageRemoteConfiguration extends OStorageConfiguration {
private static final long serialVersionUID = -3850696054909943272L;
private String networkRecordSerializer;

public OStorageRemoteConfiguration(OStorageRemote oStorageRemote, String iRecordSerializer, int serverVersion) {
super(oStorageRemote, getCharset(serverVersion));
public OStorageRemoteConfiguration(OStorageRemote oStorageRemote, String iRecordSerializer) {
super(oStorageRemote, Charset.forName("UTF-8"));

networkRecordSerializer = iRecordSerializer;
}

private static Charset getCharset(int serverVersion) {
Charset charset;
if (serverVersion >= 38)
charset = Charset.forName("UTF-8");
else
charset = Charset.defaultCharset();

return charset;
}

@Override
public String getRecordSerializer() {
return networkRecordSerializer;
Expand Down
Expand Up @@ -144,9 +144,7 @@ public class OChannelBinaryProtocol {
public static final int PROTOCOL_VERSION_36 = 36; //ABILITY TO CREATE DATABASE FROM INCREMENTAL BACKUP
public static final int PROTOCOL_VERSION_37 = 37;

public static final int PROTOCOL_VERSION_38 = 38;

public static final int CURRENT_PROTOCOL_VERSION = PROTOCOL_VERSION_38;
public static final int CURRENT_PROTOCOL_VERSION = PROTOCOL_VERSION_37;

public static OIdentifiable readIdentifiable(final OChannelDataInput network) throws IOException {
final int classId = network.readShort();
Expand Down
Expand Up @@ -234,16 +234,10 @@ public OBinaryResponse executeReadRecord(OReadRecordRequest request) {
// SEND THE DB CONFIGURATION INSTEAD SINCE IT WAS ON RECORD 0:0
OFetchHelper.checkFetchPlanValid(fetchPlanString);

Charset charset;
if (connection.getData().protocolVersion >= OChannelBinaryProtocol.PROTOCOL_VERSION_38)
charset = Charset.forName("UTF-8");
else
charset = Charset.defaultCharset();

final byte[] record = connection.getDatabase().getStorage().callInLock(new Callable<byte[]>() {
@Override
public byte[] call() throws Exception {
return connection.getDatabase().getStorage().getConfiguration().toStream(connection.getData().protocolVersion, charset);
return connection.getDatabase().getStorage().getConfiguration().toStream(connection.getData().protocolVersion, Charset.forName("UTF-8"));
}
}, false);

Expand Down Expand Up @@ -300,16 +294,10 @@ public OBinaryResponse executeReadRecordIfNotLastest(OReadRecordIfVersionIsNotLa
// SEND THE DB CONFIGURATION INSTEAD SINCE IT WAS ON RECORD 0:0
OFetchHelper.checkFetchPlanValid(fetchPlanString);

Charset charset;
if (connection.getData().protocolVersion >= OChannelBinaryProtocol.PROTOCOL_VERSION_38)
charset = Charset.forName("UTF-8");
else
charset = Charset.defaultCharset();

final byte[] record = connection.getDatabase().getStorage().callInLock(new Callable<byte[]>() {
@Override
public byte[] call() throws Exception {
return connection.getDatabase().getStorage().getConfiguration().toStream(connection.getData().protocolVersion, charset);
return connection.getDatabase().getStorage().getConfiguration().toStream(connection.getData().protocolVersion, Charset.forName("UTF-8"));
}
}, false);

Expand Down

0 comments on commit 17f0b0f

Please sign in to comment.