diff --git a/src/hotspot/os/posix/perfMemory_posix.cpp b/src/hotspot/os/posix/perfMemory_posix.cpp index c4cdb4c74f5..598955cbdfb 100644 --- a/src/hotspot/os/posix/perfMemory_posix.cpp +++ b/src/hotspot/os/posix/perfMemory_posix.cpp @@ -1205,7 +1205,10 @@ static void mmap_attach_shared(int vmid, char** addr, size_t* sizep, TRAPS) { FREE_C_HEAP_ARRAY(char, dirname); FREE_C_HEAP_ARRAY(char, filename); - if (fd == OS_ERR || HAS_PENDING_EXCEPTION) { + if (HAS_PENDING_EXCEPTION) { + assert(fd == OS_ERR, "open_sharedmem_file always return OS_ERR on exceptions"); + } + if (fd == OS_ERR) { return; } diff --git a/src/hotspot/share/compiler/directivesParser.cpp b/src/hotspot/share/compiler/directivesParser.cpp index e48ac58b31c..edb7a3af918 100644 --- a/src/hotspot/share/compiler/directivesParser.cpp +++ b/src/hotspot/share/compiler/directivesParser.cpp @@ -96,10 +96,9 @@ bool DirectivesParser::parse_from_file_inner(const char* filename, outputStream* // read contents into resource array char* buffer = NEW_RESOURCE_ARRAY(char, st.st_size+1); ssize_t num_read = ::read(file_handle, (char*) buffer, st.st_size); + ::close(file_handle); if (num_read >= 0) { buffer[num_read] = '\0'; - // close file - ::close(file_handle); return parse_string(buffer, stream) > 0; } }