Skip to content

Commit

Permalink
Eagerly disable reference mode when writing stubs and skeletons.
Browse files Browse the repository at this point in the history
  • Loading branch information
broneill committed Feb 4, 2025
1 parent f03ac7c commit bf12472
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/main/java/org/cojen/dirmi/core/BufferedPipe.java
Original file line number Diff line number Diff line change
Expand Up @@ -2383,6 +2383,17 @@ private boolean tryWriteReference(ReferenceMap refMap, Object v) throws IOExcept
}
}

/**
* If necessary, writes T_REF_MODE_OFF before writing an object.
*/
protected void refModeOffIfDisabled() throws IOException {
ReferenceMap refMap = mOutRefMap;
if (refMap != null && refMap.isDisabled()) {
write(T_REF_MODE_OFF);
mOutRefMap = null;
}
}

@Override
public final SocketAddress localAddress() {
return mLocalAddress;
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/org/cojen/dirmi/core/CorePipe.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ Class<?> loadClass(String name) throws ClassNotFoundException {

@Override
void writeStub(Stub stub) throws IOException {
refModeOffIfDisabled();
requireOutput(9);
int end = mOutEnd;
byte[] buf = mOutBuffer;
Expand All @@ -106,6 +107,7 @@ void writeSkeleton(Object server) throws IOException {
* @param typeCode T_REMOTE_T or T_REMOTE_TI
*/
void writeSkeletonHeader(byte typeCode, Skeleton skeleton) throws IOException {
refModeOffIfDisabled();
requireOutput(17);
int end = mOutEnd;
byte[] buf = mOutBuffer;
Expand Down

0 comments on commit bf12472

Please sign in to comment.