Skip to content

Commit

Permalink
enhance error handling in LobReferences
Browse files Browse the repository at this point in the history
  • Loading branch information
t-horikawa committed Jan 24, 2025
1 parent 6be8299 commit aa7c89e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ public final class BlobReferenceForSql implements BlobReference {
final SqlCommon.LargeObjectReference largeObjectReference;
Response response;

public BlobReferenceForSql(long provider, long objectId) {
public BlobReferenceForSql(SqlCommon.LargeObjectProvider provider, long objectId) {
largeObjectReference = SqlCommon.LargeObjectReference.newBuilder()
.setProvider(SqlCommon.LargeObjectProvider.forNumber((int) provider))
.setObjectId(objectId)
.build();
.setProvider(provider)
.setObjectId(objectId)
.build();
this.response = null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ public final class ClobReferenceForSql implements ClobReference {
final SqlCommon.LargeObjectReference largeObjectReference;
Response response;

public ClobReferenceForSql(long provider, long objectId) {
public ClobReferenceForSql(SqlCommon.LargeObjectProvider provider, long objectId) {
largeObjectReference = SqlCommon.LargeObjectReference.newBuilder()
.setProvider(SqlCommon.LargeObjectProvider.forNumber((int) provider))
.setObjectId(objectId)
.build();
.setProvider(provider)
.setObjectId(objectId)
.build();
this.response = null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.tsurugidb.sql.proto.SqlCommon;
import com.tsurugidb.tsubakuro.sql.BlobReference;
import com.tsurugidb.tsubakuro.sql.ClobReference;
import com.tsurugidb.tsubakuro.sql.impl.BlobReferenceForSql;
Expand Down Expand Up @@ -543,7 +544,10 @@ public DateTimeInterval readDateTimeInterval() throws IOException {
public BlobReference readBlob() throws IOException {
require(EntryType.BLOB);
clearHeaderInfo();
var provider = read8();
var provider = SqlCommon.LargeObjectProvider.forNumber((int) read8());
if (provider == null) {
throw new IOException("illegal blob provider");
}
var objectId = read8();
return new BlobReferenceForSql(provider, objectId);
}
Expand All @@ -552,7 +556,10 @@ public BlobReference readBlob() throws IOException {
public ClobReference readClob() throws IOException {
require(EntryType.CLOB);
clearHeaderInfo();
var provider = read8();
var provider = SqlCommon.LargeObjectProvider.forNumber((int) read8());
if (provider == null) {
throw new IOException("illegal clob provider");
}
var objectId = read8();
return new ClobReferenceForSql(provider, objectId);
}
Expand Down

0 comments on commit aa7c89e

Please sign in to comment.