65
65
import org .xml .sax .SAXException ;
66
66
67
67
import java .io .IOException ;
68
- import java .lang .reflect .Field ;
69
- import java .lang .reflect .InvocationTargetException ;
70
- import java .lang .reflect .Method ;
71
- import java .lang .reflect .Modifier ;
72
68
import java .nio .file .Files ;
73
69
import java .nio .file .Path ;
74
70
import java .util .*;
@@ -1414,19 +1410,12 @@ protected void assertPartialOrdered(final List<ExpectedLoggable> expectedPartial
1414
1410
/**
1415
1411
* Check point's the journal, and forces switching to a new journal file.
1416
1412
*/
1417
- protected void checkpointJournalAndSwitchFile () throws NoSuchFieldException , IllegalAccessException , TransactionException {
1413
+ protected void checkpointJournalAndSwitchFile () throws TransactionException {
1414
+ final Journal journal = existEmbeddedServer .getBrokerPool ().getJournalManager ().get ().journal ;
1418
1415
1419
1416
//set Journal#journalMinSize = 0, so that switch files will always happen
1420
- final Field fldMinReplace = Journal .class .getDeclaredField ("journalSizeMin" );
1421
- fldMinReplace .setAccessible (true );
1422
- final Field modifiersField = JDKCompatibility .getModifiersField ();
1423
- modifiersField .setAccessible ( true );
1424
- modifiersField .setInt ( fldMinReplace , fldMinReplace .getModifiers () & ~Modifier .FINAL );
1425
- final Field fldJournal = JournalManager .class .getDeclaredField ("journal" );
1426
- fldJournal .setAccessible (true );
1427
- final Journal journal = (Journal )fldJournal .get (existEmbeddedServer .getBrokerPool ().getJournalManager ().get ());
1428
- final long existingMinReplaceValue = fldMinReplace .getLong (journal );
1429
- fldMinReplace .setLong (journal , 0 );
1417
+ final long existingMinReplaceValue = journal .journalSizeMin ;
1418
+ journal .journalSizeMin = 0 ;
1430
1419
1431
1420
// checkpoint the journal and switch file
1432
1421
final BrokerPool pool = existEmbeddedServer .getBrokerPool ();
@@ -1435,7 +1424,7 @@ protected void checkpointJournalAndSwitchFile() throws NoSuchFieldException, Ill
1435
1424
}
1436
1425
1437
1426
//restore the Journal#journalMinSize to its previous value
1438
- fldMinReplace . set ( journal , existingMinReplaceValue ) ;
1427
+ journal . journalSizeMin = existingMinReplaceValue ;
1439
1428
}
1440
1429
1441
1430
protected List <Loggable > readLatestJournalEntries () throws IOException , LogException {
0 commit comments