8324657: Intermittent OOME on exception message create

Reviewed-by: lancea, iris, naoto
This commit is contained in:
Roger Riggs 2024-01-25 14:51:50 +00:00
parent e709842eae
commit ffe3bb6763

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -1987,9 +1987,8 @@ public class ObjectInputStream
resolveEx = ex;
} catch (IllegalAccessError aie) {
throw new InvalidClassException(aie.getMessage(), aie);
} catch (OutOfMemoryError memerr) {
throw new InvalidObjectException("Proxy interface limit exceeded: " +
Arrays.toString(ifaces), memerr);
} catch (OutOfMemoryError oome) {
throw genInvalidObjectException(oome, ifaces);
}
// Call filterCheck on the class before reading anything else
@ -2001,9 +2000,8 @@ public class ObjectInputStream
totalObjectRefs++;
depth++;
desc.initProxy(cl, resolveEx, readClassDesc(false));
} catch (OutOfMemoryError memerr) {
throw new InvalidObjectException("Proxy interface limit exceeded: " +
Arrays.toString(ifaces), memerr);
} catch (OutOfMemoryError oome) {
throw genInvalidObjectException(oome, ifaces);
} finally {
depth--;
}
@ -2013,6 +2011,14 @@ public class ObjectInputStream
return desc;
}
// Generate an InvalidObjectException for an OutOfMemoryError
// Use String.concat() to avoid string formatting invoke dynamic
private static InvalidObjectException genInvalidObjectException(OutOfMemoryError oome,
String[] ifaces) {
return new InvalidObjectException("Proxy interface limit exceeded: "
.concat(Arrays.toString(ifaces)), oome);
}
/**
* Reads in and returns class descriptor for a class that is not a dynamic
* proxy class. Sets passHandle to class descriptor's assigned handle. If