7091388: Regular unexplained npe's from corba libs after system has been running for days

Reviewed-by: alanb
This commit is contained in:
Sean Coffey 2011-11-11 10:16:17 +00:00
parent bf689f8a34
commit ff772aece8
4 changed files with 28 additions and 30 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -423,6 +423,13 @@ public abstract class CDRInputStream
impl.setByteBufferWithInfo(bbwi); impl.setByteBufferWithInfo(bbwi);
} }
/**
* return true if our ByteBuffer is sharing/equal to bb
*/
protected final boolean isSharing(ByteBuffer bb) {
return (getByteBuffer() == bb);
}
public final int getBufferLength() { public final int getBufferLength() {
return impl.getBufferLength(); return impl.getBufferLength();
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997, 2004, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -2412,7 +2412,6 @@ public class CDRInputStream_1_0 extends CDRInputStreamBase
if (bbwi != null && getByteBuffer() != null) if (bbwi != null && getByteBuffer() != null)
{ {
int bbHash = System.identityHashCode(bbwi.byteBuffer);
MessageMediator messageMediator = parent.getMessageMediator(); MessageMediator messageMediator = parent.getMessageMediator();
if (messageMediator != null) if (messageMediator != null)
{ {
@ -2420,19 +2419,12 @@ public class CDRInputStream_1_0 extends CDRInputStreamBase
(CDROutputObject)messageMediator.getOutputObject(); (CDROutputObject)messageMediator.getOutputObject();
if (outputObj != null) if (outputObj != null)
{ {
ByteBuffer outputBb = outputObj.getByteBuffer(); if (outputObj.isSharing(getByteBuffer()))
int oBbHash = 0;
if (outputBb != null)
{ {
oBbHash = System.identityHashCode(outputBb); // Set OutputStream's ByteBuffer and bbwi to null
if (bbHash == oBbHash) // shared? // so its ByteBuffer cannot be released to the pool
{ outputObj.setByteBuffer(null);
// Set OutputStream's ByteBuffer and bbwi to null outputObj.setByteBufferWithInfo(null);
// so its ByteBuffer cannot be released to the pool
outputObj.setByteBuffer(null);
outputObj.setByteBufferWithInfo(null);
}
} }
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -357,6 +357,13 @@ public abstract class CDROutputStream
impl.setByteBuffer(byteBuffer); impl.setByteBuffer(byteBuffer);
} }
/**
* return true if our ByteBuffer is sharing/equal to bb
*/
protected final boolean isSharing(ByteBuffer bb) {
return (getByteBuffer() == bb);
}
public final boolean isLittleEndian() { public final boolean isLittleEndian() {
return impl.isLittleEndian(); return impl.isLittleEndian();
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997, 2004, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -1902,7 +1902,6 @@ public class CDROutputStream_1_0 extends CDROutputStreamBase
if (getByteBufferWithInfo() != null && getByteBuffer() != null) if (getByteBufferWithInfo() != null && getByteBuffer() != null)
{ {
int bbHash = System.identityHashCode(bbwi.byteBuffer);
MessageMediator messageMediator = parent.getMessageMediator(); MessageMediator messageMediator = parent.getMessageMediator();
if (messageMediator != null) if (messageMediator != null)
{ {
@ -1910,19 +1909,12 @@ public class CDROutputStream_1_0 extends CDROutputStreamBase
(CDRInputObject)messageMediator.getInputObject(); (CDRInputObject)messageMediator.getInputObject();
if (inputObj != null) if (inputObj != null)
{ {
ByteBuffer inputBb = inputObj.getByteBuffer(); if (inputObj.isSharing(getByteBuffer()))
int iBbHash = 0;
if (inputBb != null)
{ {
iBbHash = System.identityHashCode(inputBb); // Set InputStream's ByteBuffer and bbwi to null
if (bbHash == iBbHash) // shared? // so its ByteBuffer cannot be released to the pool
{ inputObj.setByteBuffer(null);
// Set InputStream's ByteBuffer and bbwi to null inputObj.setByteBufferWithInfo(null);
// so its ByteBuffer cannot be released to the pool
inputObj.setByteBuffer(null);
inputObj.setByteBufferWithInfo(null);
}
} }
} }
} }