Skip to content

Commit 07602fb

Browse files
authored
Merge pull request #1552 from marklogic/feature/more-rowBatcher-cleanup
Cleaned up validation of rowsHandle in RowBatcherImpl
2 parents 564958e + 7b7ebb7 commit 07602fb

File tree

1 file changed

+25
-17
lines changed

1 file changed

+25
-17
lines changed

marklogic-client-api/src/main/java/com/marklogic/client/datamovement/impl/RowBatcherImpl.java

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -67,34 +67,42 @@ class RowBatcherImpl<T> extends BatcherImpl implements RowBatcher<T> {
6767
private final AtomicLong serverTimestamp = new AtomicLong(-1);
6868

6969
private final ContentHandle<T> rowsHandle;
70-
private final Class<T> rowsClass;
7170
private final RowManager defaultRowManager;
7271

7372
RowBatcherImpl(DataMovementManagerImpl moveMgr, ContentHandle<T> rowsHandle) {
7473
super(moveMgr);
75-
if (rowsHandle == null)
76-
throw new IllegalArgumentException("Cannot create RowBatcher with null rows manager");
77-
if (!(rowsHandle instanceof StructureReadHandle))
78-
throw new IllegalArgumentException("Rows handle must also be StructureReadHandle");
79-
if (!(rowsHandle instanceof BaseHandle))
80-
throw new IllegalArgumentException("Rows handle must also be BaseHandle");
81-
if (((BaseHandle) rowsHandle).getFormat() == Format.UNKNOWN)
82-
throw new IllegalArgumentException("Rows handle must specify a format");
74+
validateRowsHandle(rowsHandle);
8375
this.rowsHandle = rowsHandle;
84-
this.rowsClass = rowsHandle.getContentClass();
85-
if (this.rowsClass == null)
86-
throw new IllegalArgumentException("Rows handle cannot have a null content class");
87-
if (!DatabaseClientFactory.getHandleRegistry().isRegistered(this.rowsClass))
88-
throw new IllegalArgumentException(
89-
"Rows handle must be registered with DatabaseClientFactory.HandleFactoryRegistry"
90-
);
91-
defaultRowManager = getPrimaryClient().newRowManager();
76+
77+
defaultRowManager = getPrimaryClient().newRowManager();
9278
super.withBatchSize(DEFAULT_BATCH_SIZE);
9379
if (moveMgr.getConnectionType() == DatabaseClient.ConnectionType.DIRECT) {
9480
withForestConfig(moveMgr.getForestConfig());
9581
}
9682
}
9783

84+
private void validateRowsHandle(ContentHandle<T> rowsHandle) {
85+
if (rowsHandle == null) {
86+
throw new IllegalArgumentException("Cannot create RowBatcher with null rows manager");
87+
}
88+
if (!(rowsHandle instanceof StructureReadHandle)) {
89+
throw new IllegalArgumentException("Rows handle must also be StructureReadHandle");
90+
}
91+
if (!(rowsHandle instanceof BaseHandle)) {
92+
throw new IllegalArgumentException("Rows handle must also be BaseHandle");
93+
}
94+
if (((BaseHandle) rowsHandle).getFormat() == Format.UNKNOWN) {
95+
throw new IllegalArgumentException("Rows handle must specify a format");
96+
}
97+
98+
Class<T> rowsClass = rowsHandle.getContentClass();
99+
if (rowsClass == null) {
100+
throw new IllegalArgumentException("Rows handle cannot have a null content class");
101+
} else if (!DatabaseClientFactory.getHandleRegistry().isRegistered(rowsClass)) {
102+
throw new IllegalArgumentException("Rows handle must be registered with DatabaseClientFactory.HandleFactoryRegistry");
103+
}
104+
}
105+
98106
@Override
99107
public RowManager getRowManager() {
100108
return defaultRowManager;

0 commit comments

Comments
 (0)