You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Moving to Java 17 I could not get fstat of the file descriptor:
java.lang.RuntimeException: native error calling fstat: Bad file descriptor -1
at jnr.posix.util.DefaultPOSIXHandler.error(DefaultPOSIXHandler.java:24)
at jnr.posix.LinuxPOSIX.fstat(LinuxPOSIX.java:117)
at jnr.posix.CheckedPOSIX.fstat(CheckedPOSIX.java:135)
at jnr.posix.LazyPOSIX.fstat(LazyPOSIX.java:132)
at com.openwaygroup.appserver.monitoring.logprocessor.files.posix.PosixFileInformation.getFileInformation(PosixFileInformation.kt:15)
at com.openwaygroup.appserver.monitoring.logprocessor.processor.EventProcessorImpl.processEvent(EventProcessorImpl.kt:36)
at com.openwaygroup.appserver.monitoring.logprocessor.processor.EventProcessorImpl.processEvent(EventProcessorImpl.kt:19)
at com.openwaygroup.appserver.monitoring.logprocessor.application.Application$startProcessing$1$1.invokeSuspend(Application.kt:34)
at com.openwaygroup.appserver.monitoring.logprocessor.application.Application$startProcessing$1$1.invoke(Application.kt)
at com.openwaygroup.appserver.monitoring.logprocessor.application.Application$startProcessing$1$1.invoke(Application.kt)
at kotlinx.coroutines.flow.FlowKt__MergeKt$flatMapConcat$$inlined$map$1$2.emit(Emitters.kt:223)
at kotlinx.coroutines.flow.SharedFlowImpl.collect$suspendImpl(SharedFlow.kt:372)
at kotlinx.coroutines.flow.SharedFlowImpl$collect$1.invokeSuspend(SharedFlow.kt)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:840)
The code:
...
val fileInputStream = FileInputStream(file)
val fileId = fileInfoSpec.getFileInformation(fileInputStream.fd) //fileInfoSpec is an interface, implemented for Windows and Posix (see below)
...
//Posix systems:
...
private val posix = POSIXFactory.getPOSIX()
...
override fun getFileInformation(fd: FileDescriptor): String? {
try {
val fstat = posix.fstat(fd)
...
//Windows:
private val windowsPOSIX = POSIXFactory.getNativePOSIX() as WindowsPOSIX
private val windowsLibC = windowsPOSIX.libc() as WindowsLibC
private val serialNumberField = WindowsByHandleFileInformation::class.java.getDeclaredField("dwVolumeSerialNumber")
private val fileIndexHighField = WindowsByHandleFileInformation::class.java.getDeclaredField("nFileIndexHigh")
private val fileIndexLowField = WindowsByHandleFileInformation::class.java.getDeclaredField("nFileIndexLow")
init {
serialNumberField.isAccessible = true
fileIndexHighField.isAccessible = true
fileIndexLowField.isAccessible = true
}
...
override fun getFileInformation(fd: FileDescriptor): String? {
try {
val handle = JavaLibCHelper.gethandle(fd)
if (handle.isValid) {
val byHandle = WindowsByHandleFileInformation(Runtime.getSystemRuntime())
if (windowsLibC.GetFileInformationByHandle(handle, byHandle) > 0) {
val serialNumber = serialNumberField.get(windowsFileInformation) as Unsigned32
val lowIndex = fileIndexLowField.get(windowsFileInformation) as Unsigned32
val highIndex = fileIndexHighField.get(windowsFileInformation) as Unsigned32
Could it be related to the reflection warnings I got on Java 11?
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by jnr.posix.JavaLibCHelper$ReflectiveAccess (file:/C:/Users/yshupletsov/.gradle/caches/modules-2/files-2.1/com.github.jnr/jnr-posix/3.1.19/cc55c9e55541895498acdfd59c3145dff91db6e7/jnr-posix-3.1.19.jar) to method sun.nio.ch.SelChImpl.getFD()
WARNING: Please consider reporting this to the maintainers of jnr.posix.JavaLibCHelper$ReflectiveAccess
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Running the code with --add-opens java.base/sun.nio.ch=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED has no success as well.
The text was updated successfully, but these errors were encountered:
Moving to Java 17 I could not get fstat of the file descriptor:
The code:
Could it be related to the reflection warnings I got on Java 11?
Running the code with --add-opens java.base/sun.nio.ch=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED has no success as well.
The text was updated successfully, but these errors were encountered: