This is an automated email from the ASF dual-hosted git repository. jamesbognar pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/juneau.git
The following commit(s) were added to refs/heads/master by this push: new 8a3fd0896 JUNEAU-251 Test failures on Java 20 new 703b55915 Merge branch 'master' of https://gitbox.apache.org/repos/asf/juneau.git 8a3fd0896 is described below commit 8a3fd0896ec48c82b6c26812d1f182f024772c52 Author: JamesBognar <james.bog...@salesforce.com> AuthorDate: Tue Sep 5 13:01:56 2023 -0400 JUNEAU-251 Test failures on Java 20 --- .../org/apache/juneau/html/HtmlParserSession.java | 4 +-- .../java/org/apache/juneau/swap/DefaultSwaps.java | 2 ++ .../main/java/org/apache/juneau/swaps/UrlSwap.java | 38 ++++++++++++++++++++++ 3 files changed, 42 insertions(+), 2 deletions(-) diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlParserSession.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlParserSession.java index 55a634b60..fc9e961d6 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlParserSession.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlParserSession.java @@ -352,7 +352,7 @@ public final class HtmlParserSession extends XmlParserSession { skipTag(r, xNULL); } else if (tag == A) { - o = parseAnchor(r, eType); + o = parseAnchor(r, swap == null ? eType : null); skipTag(r, xA); } else if (tag == TABLE) { @@ -473,7 +473,7 @@ public final class HtmlParserSession extends XmlParserSession { throws IOException, ParseException, XMLStreamException { String href = r.getAttributeValue(null, "href"); String name = getElementText(r); - if (beanType.hasAnnotation(HtmlLink.class)) { + if (beanType != null && beanType.hasAnnotation(HtmlLink.class)) { Value<String> uriProperty = Value.empty(), nameProperty = Value.empty(); beanType.forEachAnnotation(HtmlLink.class, x -> isNotEmpty(x.uriProperty()), x -> uriProperty.set(x.uriProperty())); beanType.forEachAnnotation(HtmlLink.class, x -> isNotEmpty(x.nameProperty()), x -> nameProperty.set(x.nameProperty())); diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/swap/DefaultSwaps.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/swap/DefaultSwaps.java index caf2406b1..03948dceb 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/swap/DefaultSwaps.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/swap/DefaultSwaps.java @@ -12,6 +12,7 @@ // *************************************************************************************************************************** package org.apache.juneau.swap; +import java.net.*; import java.time.*; import java.time.temporal.*; import java.util.*; @@ -55,6 +56,7 @@ public class DefaultSwaps { SWAPS.put(XMLGregorianCalendar.class, new XMLGregorianCalendarSwap()); SWAPS.put(ZoneId.class, new ZoneIdSwap()); SWAPS.put(MatchResult.class, new MatchResultSwap()); + SWAPS.put(URL.class, new UrlSwap()); } /** diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/swaps/UrlSwap.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/swaps/UrlSwap.java new file mode 100644 index 000000000..826d4f4cd --- /dev/null +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/swaps/UrlSwap.java @@ -0,0 +1,38 @@ +// *************************************************************************************************************************** +// * 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.juneau.swaps; + +import java.net.*; + +import org.apache.juneau.*; +import org.apache.juneau.swap.*; + +/** + * Transforms {@link URL} objects to and from {@link String Strings}. + * + * <h5 class='section'>See Also:</h5><ul> + * <li class='link'><a class="doclink" href="../../../../index.html#jm.Swaps">Swaps</a> + * </ul> + */ +public class UrlSwap extends StringSwap<URL> { + + @Override /* ObjectSwap */ + public String swap(BeanSession session, URL o) throws Exception { + return o.toString(); + } + + @Override /* ObjectSwap */ + public URL unswap(BeanSession session, String o, ClassMeta<?> hint) throws Exception { + return new URI(o).toURL(); + } +}