Skip to content

Commit

Permalink
TECH: Dump: throw when writing meta-data in read-only mode
Browse files Browse the repository at this point in the history
  • Loading branch information
c247t committed Dec 20, 2023
1 parent bcbba48 commit 61e0e20
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions dump/src/util/dump/Dump.java
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,9 @@ public void close() throws IOException {
if ( _updateRaf != null ) {
_updateRaf.close();
}
writeMeta();
if ( !isReadonly() ) {
writeMeta();
}
if ( _metaRaf != null ) {
_metaRaf.close();
_metaRaf = null;
Expand Down Expand Up @@ -489,7 +491,7 @@ public void flush() throws IOException {
*/
public void flushMeta() throws IOException {
if ( isReadonly() ) {
return;
throw new AccessControlException("Flushing meta-data not allowed in read-only mode.");
}

writeMeta();
Expand Down Expand Up @@ -846,6 +848,10 @@ public E updateLast( E item ) throws IOException {
* @return false if the dump was already locked
*/
protected boolean acquireFileLock() {
if ( isReadonly() ) {
return false;
}

synchronized ( this ) {
try {
if ( _dumpLock != null ) {
Expand Down Expand Up @@ -1068,7 +1074,7 @@ void writeDictionary() throws IOException {

void writeMeta() throws IOException {
if ( isReadonly() ) {
return;
throw new AccessControlException("Writing meta-data not allowed in read-only mode.");
}

getMetaRAF().seek(0);
Expand Down

0 comments on commit 61e0e20

Please sign in to comment.