Skip to content

Commit 6d121fc

Browse files
Set debug flags using options, remove usePreviousCommitOnValida....
1 parent 415f6b7 commit 6d121fc

File tree

2 files changed

+12
-39
lines changed

2 files changed

+12
-39
lines changed

objectbox-java/src/main/java/io/objectbox/BoxStore.java

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,6 @@ public static String getVersionNative() {
139139
*/
140140
public static native void testUnalignedMemoryAccess();
141141

142-
/**
143-
* @deprecated Use {@link #nativeCreateWithFlatOptions(byte[], byte[])} instead.
144-
*/
145-
@Deprecated
146-
static native long nativeCreate(String directory, long maxDbSizeInKByte, int maxReaders, byte[] model);
147-
148142
/**
149143
* Creates a native BoxStore instance with FlatBuffer {@link io.objectbox.model.FlatStoreOptions} {@code options}
150144
* and a {@link ModelBuilder} {@code model}. Returns the handle of the native store instance.
@@ -234,7 +228,6 @@ public static boolean isObjectBrowserAvailable() {
234228
handle = nativeCreateWithFlatOptions(buildFlatStoreOptions(builder, canonicalPath), builder.model);
235229
int debugFlags = builder.debugFlags;
236230
if (debugFlags != 0) {
237-
nativeSetDebugFlags(handle, debugFlags);
238231
debugTxRead = (debugFlags & DebugFlags.LOG_TRANSACTIONS_READ) != 0;
239232
debugTxWrite = (debugFlags & DebugFlags.LOG_TRANSACTIONS_WRITE) != 0;
240233
} else {
@@ -289,17 +282,20 @@ private byte[] buildFlatStoreOptions(BoxStoreBuilder builder, String canonicalPa
289282
FlatStoreOptions.addDirectoryPath(fbb, directoryPathOffset);
290283
FlatStoreOptions.addMaxDbSizeInKByte(fbb, builder.maxSizeInKByte);
291284
FlatStoreOptions.addMaxReaders(fbb, builder.maxReaders);
292-
// FlatStoreOptions.addDebugFlags(fbb, builder.debugFlags); // TODO Use this instead of nativeSetDebugFlags?
293-
// TODO Add new values.
294-
FlatStoreOptions.addReadOnly(fbb, builder.readOnly);
295-
FlatStoreOptions.addUsePreviousCommit(fbb, builder.usePreviousCommit);
296-
FlatStoreOptions.addUsePreviousCommitOnValidationFailure(fbb, builder.usePreviousCommitOnValidationFailure);
297-
if (builder.validateOnOpenMode != 0) {
298-
FlatStoreOptions.addValidateOnOpen(fbb, builder.validateOnOpenMode);
299-
if (builder.validateOnOpenPageLimit != 0) {
300-
FlatStoreOptions.addValidateOnOpenPageLimit(fbb, builder.validateOnOpenPageLimit);
285+
int validateOnOpenMode = builder.validateOnOpenMode;
286+
if (validateOnOpenMode != 0) {
287+
FlatStoreOptions.addValidateOnOpen(fbb, validateOnOpenMode);
288+
long validateOnOpenPageLimit = builder.validateOnOpenPageLimit;
289+
if (validateOnOpenPageLimit != 0) {
290+
FlatStoreOptions.addValidateOnOpenPageLimit(fbb, validateOnOpenPageLimit);
301291
}
302292
}
293+
FlatStoreOptions.addUsePreviousCommit(fbb, builder.usePreviousCommit);
294+
FlatStoreOptions.addReadOnly(fbb, builder.readOnly);
295+
int debugFlags = builder.debugFlags;
296+
if (debugFlags != 0) {
297+
FlatStoreOptions.addDebugFlags(fbb, debugFlags);
298+
}
303299

304300
int offset = FlatStoreOptions.endFlatStoreOptions(fbb);
305301
fbb.finish(offset);

objectbox-java/src/main/java/io/objectbox/BoxStoreBuilder.java

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ public class BoxStoreBuilder {
9494

9595
boolean readOnly;
9696
boolean usePreviousCommit;
97-
boolean usePreviousCommitOnValidationFailure;
9897

9998
int validateOnOpenMode;
10099
long validateOnOpenPageLimit;
@@ -325,32 +324,10 @@ public BoxStoreBuilder readOnly() {
325324
* It is recommended to use this with {@link #readOnly()} to ensure no data is lost.
326325
*/
327326
public BoxStoreBuilder usePreviousCommit() {
328-
if (usePreviousCommitOnValidationFailure) {
329-
throw new IllegalStateException("Can not use together with usePreviousCommitOnValidationFailure()");
330-
}
331327
this.usePreviousCommit = true;
332328
return this;
333329
}
334330

335-
/**
336-
* If consistency checks fail during opening the DB, ObjectBox
337-
* automatically switches to the previous commit. This way, this constitutes
338-
* an auto-recover mode from severe failures.
339-
* <p>
340-
* However, keep in mind that any consistency failure
341-
* is an indication that something is very wrong with OS/hardware and thus you may possibly alert your users.
342-
*
343-
* @see #usePreviousCommit()
344-
* @see #validateOnOpen(int)
345-
*/
346-
public BoxStoreBuilder usePreviousCommitOnValidationFailure() {
347-
if (usePreviousCommit) {
348-
throw new IllegalStateException("Can not use together with usePreviousCommit()");
349-
}
350-
this.usePreviousCommitOnValidationFailure = true;
351-
return this;
352-
}
353-
354331
/**
355332
* When a database is opened, ObjectBox can perform additional consistency checks on its database structure.
356333
* Reliable file systems already guarantee consistency, so this is primarily meant to deal with unreliable

0 commit comments

Comments
 (0)