Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ungreat committed Jul 11, 2024
1 parent b7fcb91 commit 43605dc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,9 @@ public String generateStateId(String type) {
return Base64.getEncoder().encodeToString(JsonUtils.toJson(uuidStateId).getBytes(StandardCharsets.UTF_8));
}

public static StatefulUuidStateId parseStateId(String stateId) {
return JsonUtils.fromJson(new String(Base64.getDecoder().decode(stateId)),
StatefulUuidStateId.class);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,11 @@
*/
package com.oceanbase.odc.service.state;

import java.util.Base64;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;

import com.google.common.base.Preconditions;
import com.oceanbase.odc.common.json.JsonUtils;
import com.oceanbase.odc.service.common.model.HostProperties;
import com.oceanbase.odc.service.state.model.RouteInfo;
import com.oceanbase.odc.service.state.model.StateManager;
Expand All @@ -38,9 +35,7 @@ public class StatefulUuidStateIdManager implements StateManager {
@Override
public RouteInfo getRouteInfo(Object stateId) {
Preconditions.checkArgument(stateId instanceof String, "stateId");
StatefulUuidStateId statefulUuidStateId =
JsonUtils.fromJson(new String(Base64.getDecoder().decode((String) stateId)),
StatefulUuidStateId.class);
StatefulUuidStateId statefulUuidStateId = StatefulUuidStateIdGenerator.parseStateId((String) stateId);
return new RouteInfo(statefulUuidStateId.getFrom(), hostProperties.getRequestPort());
}
}

0 comments on commit 43605dc

Please sign in to comment.