Repository: wicket Updated Branches: refs/heads/WICKET-6419 e75cb2560 -> 77dee2bbd
WICKET-6419 Localization of PageParameters Add some checks to be on the safe side. Project: http://git-wip-us.apache.org/repos/asf/wicket/repo Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/77dee2bb Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/77dee2bb Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/77dee2bb Branch: refs/heads/WICKET-6419 Commit: 77dee2bbd513db2ee89eb4882e02142f1fa619cd Parents: e75cb25 Author: Martin Tzvetanov Grigorov <mgrigo...@apache.org> Authored: Tue Jul 18 23:45:58 2017 +0200 Committer: Martin Tzvetanov Grigorov <mgrigo...@apache.org> Committed: Tue Jul 18 23:45:58 2017 +0200 ---------------------------------------------------------------------- .../request/mapper/AbstractBookmarkableMapper.java | 5 ++++- .../mapper/BasicResourceReferenceMapper.java | 5 ++++- .../core/request/mapper/BookmarkableMapper.java | 5 ++++- .../wicket/core/request/mapper/ResourceMapper.java | 10 ++++++++-- .../mapper/LocaleAwarePageParametersTest.java | 16 ++++++++++++++++ .../core/request/mapper/ResourceMapperTest.java | 2 -- .../request/mapper/parameter/PageParameters.java | 2 +- 7 files changed, 37 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/wicket/blob/77dee2bb/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/AbstractBookmarkableMapper.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/AbstractBookmarkableMapper.java b/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/AbstractBookmarkableMapper.java index 9cc0597..a6bab53 100644 --- a/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/AbstractBookmarkableMapper.java +++ b/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/AbstractBookmarkableMapper.java @@ -626,7 +626,10 @@ public abstract class AbstractBookmarkableMapper extends AbstractComponentMapper for (int curMatchSize : matchedParameters) total += curMatchSize; PageParameters pageParameters = extractPageParameters(request, total, pageParametersEncoder); - pageParameters.setLocale(resolveLocale()); + if (pageParameters != null) + { + pageParameters.setLocale(resolveLocale()); + } int skippedParameters = 0; for (int pathSegmentIndex = 0; pathSegmentIndex < pathSegments.size(); pathSegmentIndex++) http://git-wip-us.apache.org/repos/asf/wicket/blob/77dee2bb/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/BasicResourceReferenceMapper.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/BasicResourceReferenceMapper.java b/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/BasicResourceReferenceMapper.java index aeaf81b..d0f1375 100755 --- a/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/BasicResourceReferenceMapper.java +++ b/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/BasicResourceReferenceMapper.java @@ -93,7 +93,10 @@ public class BasicResourceReferenceMapper extends AbstractResourceReferenceMappe // extract the PageParameters from URL if there are any PageParameters pageParameters = extractPageParameters(request, segmentsSize, pageParametersEncoder); - pageParameters.setLocale(resolveLocale()); + if (pageParameters != null) + { + pageParameters.setLocale(resolveLocale()); + } String className = url.getSegments().get(2); StringBuilder name = new StringBuilder(segmentsSize * 2); http://git-wip-us.apache.org/repos/asf/wicket/blob/77dee2bb/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/BookmarkableMapper.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/BookmarkableMapper.java b/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/BookmarkableMapper.java index 5388fcb..899500e 100644 --- a/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/BookmarkableMapper.java +++ b/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/BookmarkableMapper.java @@ -123,7 +123,10 @@ public class BookmarkableMapper extends AbstractBookmarkableMapper // extract the PageParameters from URL if there are any PageParameters pageParameters = extractPageParameters(request, 3, pageParametersEncoder); - pageParameters.setLocale(resolveLocale()); + if (pageParameters != null) + { + pageParameters.setLocale(resolveLocale()); + } return new UrlInfo(info, pageClass, pageParameters); } http://git-wip-us.apache.org/repos/asf/wicket/blob/77dee2bb/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/ResourceMapper.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/ResourceMapper.java b/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/ResourceMapper.java index 8d8b0fa..69f82f7 100644 --- a/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/ResourceMapper.java +++ b/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/ResourceMapper.java @@ -126,7 +126,10 @@ public class ResourceMapper extends AbstractBookmarkableMapper // now extract the page parameters from the request url PageParameters parameters = extractPageParameters(request, mountSegments.length, parametersEncoder); - parameters.setLocale(resolveLocale()); + if (parameters != null) + { + parameters.setLocale(resolveLocale()); + } // remove caching information from current request removeCachingDecoration(url, parameters); @@ -175,7 +178,10 @@ public class ResourceMapper extends AbstractBookmarkableMapper { Url originalUrl = new Url(request.getUrl()); PageParameters parameters = extractPageParameters(request, mountSegments.length, parametersEncoder); - parameters.setLocale(resolveLocale()); + if (parameters != null) + { + parameters.setLocale(resolveLocale()); + } removeCachingDecoration(originalUrl, parameters); Request requestWithoutDecoration = request.cloneWithUrl(originalUrl); http://git-wip-us.apache.org/repos/asf/wicket/blob/77dee2bb/wicket-core/src/test/java/org/apache/wicket/core/request/mapper/LocaleAwarePageParametersTest.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/test/java/org/apache/wicket/core/request/mapper/LocaleAwarePageParametersTest.java b/wicket-core/src/test/java/org/apache/wicket/core/request/mapper/LocaleAwarePageParametersTest.java index 3087312..6a4bc88 100644 --- a/wicket-core/src/test/java/org/apache/wicket/core/request/mapper/LocaleAwarePageParametersTest.java +++ b/wicket-core/src/test/java/org/apache/wicket/core/request/mapper/LocaleAwarePageParametersTest.java @@ -1,3 +1,19 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.wicket.core.request.mapper; import static org.hamcrest.Matchers.is; http://git-wip-us.apache.org/repos/asf/wicket/blob/77dee2bb/wicket-core/src/test/java/org/apache/wicket/core/request/mapper/ResourceMapperTest.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/test/java/org/apache/wicket/core/request/mapper/ResourceMapperTest.java b/wicket-core/src/test/java/org/apache/wicket/core/request/mapper/ResourceMapperTest.java index 6603c7b..cc00db8 100644 --- a/wicket-core/src/test/java/org/apache/wicket/core/request/mapper/ResourceMapperTest.java +++ b/wicket-core/src/test/java/org/apache/wicket/core/request/mapper/ResourceMapperTest.java @@ -34,8 +34,6 @@ import org.apache.wicket.util.tester.WicketTestCase; import org.junit.Before; import org.junit.Test; -/** - */ public class ResourceMapperTest extends WicketTestCase { private static final Charset CHARSET = Charset.forName("UTF-8"); http://git-wip-us.apache.org/repos/asf/wicket/blob/77dee2bb/wicket-request/src/main/java/org/apache/wicket/request/mapper/parameter/PageParameters.java ---------------------------------------------------------------------- diff --git a/wicket-request/src/main/java/org/apache/wicket/request/mapper/parameter/PageParameters.java b/wicket-request/src/main/java/org/apache/wicket/request/mapper/parameter/PageParameters.java index e1ce701..d4736e5 100644 --- a/wicket-request/src/main/java/org/apache/wicket/request/mapper/parameter/PageParameters.java +++ b/wicket-request/src/main/java/org/apache/wicket/request/mapper/parameter/PageParameters.java @@ -411,7 +411,7 @@ public class PageParameters implements IClusterable, IIndexedParameters, INamedP */ public PageParameters mergeWith(final PageParameters other) { - if (this != other) + if (other != null && this != other) { for (int index = 0; index < other.getIndexedCount(); index++) {