8218960: CONFIG level logging statements printed in CLDRCalendarDataProviderImpl.java even when default log Level is INFO
Reviewed-by: nishjain, rriggs
This commit is contained in:
parent
e58a4da301
commit
86e513bd48
src/java.base/share/classes/sun/util
cldr
locale/provider
test/jdk/sun/util/locale/provider
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2019, 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
|
||||
@ -80,7 +80,8 @@ public class CLDRCalendarDataProviderImpl extends CalendarDataProviderImpl {
|
||||
String region = locale.getCountry();
|
||||
|
||||
if (region.isEmpty()) {
|
||||
return 0;
|
||||
// Use "US" as default
|
||||
region = "US";
|
||||
}
|
||||
|
||||
Integer val = map.get(region);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2019, 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
|
||||
@ -256,7 +256,9 @@ public class CalendarDataUtility {
|
||||
default:
|
||||
throw new InternalError("invalid requestID: " + requestID);
|
||||
}
|
||||
return (value != 0) ? value : null;
|
||||
|
||||
assert value != 0;
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2019, 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
|
||||
@ -283,8 +283,8 @@ public final class LocaleServiceProviderPool {
|
||||
return providersObj;
|
||||
} else if (isObjectProvider) {
|
||||
config(LocaleServiceProviderPool.class,
|
||||
"A locale sensitive service provider returned null for a localized objects, which should not happen. provider: "
|
||||
+ lsp + " locale: " + locale);
|
||||
"A locale sensitive service object provider returned null, " +
|
||||
"which should not happen. Provider: " + lsp + " Locale: " + locale);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (c) 2019, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8218960
|
||||
* @modules java.base/sun.util.locale.provider
|
||||
* @modules java.logging
|
||||
* @summary Check that no CONFIG messages are logged on instantiating
|
||||
* SimpleDateFormat with the language-only locale.
|
||||
* @run main CheckLoggingFromLocaleProvider
|
||||
*/
|
||||
import java.text.*;
|
||||
import java.util.*;
|
||||
import java.util.logging.*;
|
||||
import sun.util.locale.provider.*;
|
||||
|
||||
public class CheckLoggingFromLocaleProvider extends StreamHandler {
|
||||
|
||||
@Override
|
||||
public boolean isLoggable(LogRecord lr) {
|
||||
if (lr.getLevel() == Level.CONFIG &&
|
||||
lr.getLoggerName().equals(
|
||||
LocaleServiceProviderPool.class.getCanonicalName())) {
|
||||
throw new RuntimeException("CONFIG message was logged in " +
|
||||
lr.getLoggerName() + ". Message: " + lr.getMessage());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public CheckLoggingFromLocaleProvider() {
|
||||
setLevel(Level.CONFIG);
|
||||
Logger l = LogManager.getLogManager().getLogger("");
|
||||
l.setLevel(Level.CONFIG);
|
||||
l.addHandler(this);
|
||||
|
||||
new SimpleDateFormat("", Locale.ENGLISH);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
new CheckLoggingFromLocaleProvider();
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user