+ // Ugly hack to deal with logback changing its api
+ private static final Field MAX_FILE_SIZE_FIELD;
+ static {
+ Field f;
+ try {
+ f = SizeBasedTriggeringPolicy.class.getDeclaredField("maxFileSize");
+ f.setAccessible(true);
+ } catch (NoSuchFieldException | SecurityException e) {
+ throw new ExceptionInInitializerError(e);
+ }
+
+ MAX_FILE_SIZE_FIELD = f;
+ }
+
+ @VisibleForTesting
+ static FileSize getMaxFileSize(SizeBasedTriggeringPolicy<?> policy) {
+ try {
+ return (FileSize) MAX_FILE_SIZE_FIELD.get(policy);
+ } catch (IllegalArgumentException | IllegalAccessException e) {
+ throw new IllegalStateException("Cannot get maxFileSize field", e);
+ }
+ }