java.util.logging.FileHandler integer overflow prevents file rotation

Jason Mehrens jason_mehrens at hotmail.com
Tue Aug 19 14:00:07 UTC 2014


Stanimir,


Looks like the int overflow on the metered stream is an issue that hasn't been tracked.  The other issues have been reported under https://bugs.openjdk.java.net/browse/JDK-6433253

and https://bugs.openjdk.java.net/browse/JDK-8028786


Jason




----------------------------------------
> Date: Tue, 19 Aug 2014 11:06:27 +0300
> Subject: java.util.logging.FileHandler integer overflow prevents file rotation
> From: stanimir at riflexo.com
> To: core-libs-dev at openjdk.java.net
>
> java.util.logging.FileHandler uses ints to track the written bytes
> that can cause negative value for
> java.util.logging.FileHandler.MeteredStream.written as there is no
> check in any of the write methods.
> The overflow prevents the check in FileHandler.publish(LogRecord)
> meter.written>= limit to ever trigger, esp. setting limit to
> Integer.MAX_VALUE that effectively always prevents file rotation.
>
> On a flip note, MeteredStream should be a static class.
> On another flip note, FileHandler should be using long as part of the
> API and internal implementation. ints are limited to 2GiB even when
> properly implemented that's a relatively low amount for certain types
> of logging files. So I propose adding overloaded c-tors
> FileHandler(String pattern, long limit, int count, boolean append)
> and FileHandler(String pattern, long limit, int count). LogManager
> should have a method "long getLongProperty(String name, long
> defaultValue)" to initialize limit.
>
> Thanks
> Stanimir 		 	   		  


More information about the core-libs-dev mailing list