Skip to content

Commit 3e8a231

Browse files
Add docs to SchemaException, other docs changes, match with Dart.
1 parent 95ebdb1 commit 3e8a231

File tree

6 files changed

+34
-15
lines changed

6 files changed

+34
-15
lines changed

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

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import io.objectbox.exception.DbException;
3737
import io.objectbox.exception.DbFullException;
3838
import io.objectbox.exception.DbMaxDataSizeExceededException;
39+
import io.objectbox.exception.DbMaxReadersExceededException;
3940
import io.objectbox.flatbuffers.FlatBufferBuilder;
4041
import io.objectbox.ideasonly.ModelUpdate;
4142
import io.objectbox.model.FlatStoreOptions;
@@ -291,18 +292,18 @@ public BoxStoreBuilder fileMode(int mode) {
291292
}
292293

293294
/**
294-
* Sets the maximum number of concurrent readers. For most applications, the default is fine (~ 126 readers).
295+
* Sets the maximum number of concurrent readers. For most applications, the default is fine (about 126 readers).
295296
* <p>
296-
* A "reader" is short for a thread involved in a read transaction.
297+
* A "reader" is short for a thread involved in a read transaction. If the maximum is exceeded the store throws
298+
* {@link DbMaxReadersExceededException}. In this case check that your code only uses a reasonable amount of
299+
* threads.
297300
* <p>
298-
* If you hit {@link io.objectbox.exception.DbMaxReadersExceededException}, you should first worry about the
299-
* amount of threads you are using.
300301
* For highly concurrent setups (e.g. you are using ObjectBox on the server side) it may make sense to increase the
301302
* number.
302303
* <p>
303304
* Note: Each thread that performed a read transaction and is still alive holds on to a reader slot.
304305
* These slots only get vacated when the thread ends. Thus, be mindful with the number of active threads.
305-
* Alternatively, you can opt to try the experimental noReaderThreadLocals option flag.
306+
* Alternatively, you can try the experimental {@link #noReaderThreadLocals()} option flag.
306307
*/
307308
public BoxStoreBuilder maxReaders(int maxReaders) {
308309
this.maxReaders = maxReaders;
@@ -460,8 +461,8 @@ public BoxStoreBuilder debugRelations() {
460461
/**
461462
* For massive concurrent setups (app is using a lot of threads), you can enable automatic retries for queries.
462463
* This can resolve situations in which resources are getting sparse (e.g.
463-
* {@link io.objectbox.exception.DbMaxReadersExceededException} or other variations of
464-
* {@link io.objectbox.exception.DbException} are thrown during query execution).
464+
* {@link DbMaxReadersExceededException} or other variations of
465+
* {@link DbException} are thrown during query execution).
465466
*
466467
* @param queryAttempts number of attempts a query find operation will be executed before failing.
467468
* Recommended values are in the range of 2 to 5, e.g. a value of 3 as a starting point.

objectbox-java/src/main/java/io/objectbox/exception/DbMaxReadersExceededException.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121

2222
/**
2323
* Thrown when the maximum of readers (read transactions) was exceeded.
24-
* Verify that you run a reasonable amount of threads only.
24+
* Verify that your code only uses a reasonable amount of threads.
2525
* <p>
26-
* If you intend to work with a very high number of threads (&gt;100), consider increasing the number of maximum readers
26+
* If a very high number of threads (&gt;100) needs to be used, consider increasing the number of maximum readers
2727
* using {@link BoxStoreBuilder#maxReaders(int)} and enabling query retries using
2828
* {@link BoxStoreBuilder#queryAttempts(int)}.
2929
* <p>

objectbox-java/src/main/java/io/objectbox/exception/DbSchemaException.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,15 @@
1616

1717
package io.objectbox.exception;
1818

19+
/**
20+
* Thrown when there is an error with the data schema (data model).
21+
* <p>
22+
* Typically, there is a conflict between the data model defined in your code (using {@link io.objectbox.annotation.Entity @Entity}
23+
* classes) and the data model of the existing database file.
24+
* <p>
25+
* Read the <a href="https://docs.objectbox.io/advanced/meta-model-ids-and-uids#resolving-meta-model-conflicts">meta model docs</a>
26+
* on why this can happen and how to resolve such conflicts.
27+
*/
1928
public class DbSchemaException extends DbException {
2029
public DbSchemaException(String message) {
2130
super(message);

objectbox-java/src/main/java/io/objectbox/exception/DbShutdownException.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
package io.objectbox.exception;
1818

1919
/**
20-
* Thrown when an error occurred that requires the DB to shutdown.
21-
* This may be an I/O error for example.
22-
* Regular operations won't be possible anymore.
23-
* To handle that situation you could exit the app or try to reopen the store.
20+
* Thrown when an error occurred that requires the store to be closed.
21+
* <p>
22+
* This may be an I/O error. Regular operations won't be possible.
23+
* To handle this exit the app or try to reopen the store.
2424
*/
2525
public class DbShutdownException extends DbException {
2626
public DbShutdownException(String message) {

objectbox-java/src/main/java/io/objectbox/exception/FileCorruptException.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,14 @@
1515
*/
1616
package io.objectbox.exception;
1717

18-
/** Errors were detected in a file, e.g. illegal values or structural inconsistencies. */
18+
import io.objectbox.BoxStoreBuilder;
19+
20+
/**
21+
* Errors were detected in a database file, e.g. illegal values or structural inconsistencies.
22+
* <p>
23+
* It may be possible to re-open the store with {@link BoxStoreBuilder#usePreviousCommit()} to restore
24+
* to a working state.
25+
*/
1926
public class FileCorruptException extends DbException {
2027
public FileCorruptException(String message) {
2128
super(message);

objectbox-java/src/main/java/io/objectbox/exception/PagesCorruptException.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
*/
1616
package io.objectbox.exception;
1717

18-
/** Errors were detected in a file related to pages, e.g. illegal values or structural inconsistencies. */
18+
/**
19+
* Errors related to pages were detected in a database file, e.g. bad page refs outside of the file.
20+
*/
1921
public class PagesCorruptException extends FileCorruptException {
2022
public PagesCorruptException(String message) {
2123
super(message);

0 commit comments

Comments
 (0)