Skip to content

Commit

Permalink
Stop referring to JDK 1.5 plus polishing
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrannen committed Mar 14, 2024
1 parent 8e2134c commit e1b1435
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 81 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -315,7 +315,7 @@ private Object attemptToConvertStringToEnum(Class<?> requiredType, String trimme
}

if (convertedValue == currentConvertedValue) {
// Try field lookup as fallback: for JDK 1.5 enum or custom enum
// Try field lookup as fallback: for Java enum or custom enum
// with values defined as static fields. Resulting value still needs
// to be checked, hence we don't return it right away.
try {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -439,7 +439,7 @@ protected Object doInvoke(MethodInvocation invocation) throws Throwable {
throw ex.getTargetError();
}
catch (RuntimeOperationsException ex) {
// This one is only thrown by the JMX 1.2 RI, not by the JDK 1.5 JMX code.
// This one is only thrown by the JMX 1.2 RI, not by the JDK JMX code.
RuntimeException rex = ex.getTargetException();
if (rex instanceof RuntimeMBeanException runtimeMBeanException) {
throw runtimeMBeanException.getTargetException();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -80,7 +80,7 @@ public void setPropertiesArray(Properties... propertiesArray) {
/**
* Set a location of a properties file to be loaded.
* <p>Can point to a classic properties file or to an XML file
* that follows JDK 1.5's properties XML format.
* that follows Java's properties XML format.
*/
public void setLocation(Resource location) {
this.locations = new Resource[] {location};
Expand All @@ -89,7 +89,7 @@ public void setLocation(Resource location) {
/**
* Set locations of properties files to be loaded.
* <p>Can point to classic properties files or to XML files
* that follow JDK 1.5's properties XML format.
* that follow Java's properties XML format.
* <p>Note: Properties defined in later files will override
* properties defined earlier files, in case of overlapping keys.
* Hence, make sure that the most specific files are the last
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -255,9 +255,8 @@ public interface JdbcOperations {
* <p>The results will be mapped to an SqlRowSet which holds the data in a
* disconnected fashion. This wrapper will translate any SQLExceptions thrown.
* <p>Note that, for the default implementation, JDBC RowSet support needs to
* be available at runtime: by default, Sun's {@code com.sun.rowset.CachedRowSetImpl}
* class is used, which is part of JDK 1.5+ and also available separately as part of
* Sun's JDBC RowSet Implementations download (rowset.jar).
* be available at runtime: by default, a standard JDBC {@code CachedRowSet}
* is used.
* @param sql the SQL query to execute
* @return an SqlRowSet representation (possibly a wrapper around a
* {@code javax.sql.rowset.CachedRowSet})
Expand Down Expand Up @@ -874,9 +873,8 @@ <T> List<T> queryForList(String sql, Object[] args, int[] argTypes, Class<T> ele
* <p>The results will be mapped to an SqlRowSet which holds the data in a
* disconnected fashion. This wrapper will translate any SQLExceptions thrown.
* <p>Note that, for the default implementation, JDBC RowSet support needs to
* be available at runtime: by default, Sun's {@code com.sun.rowset.CachedRowSetImpl}
* class is used, which is part of JDK 1.5+ and also available separately as part of
* Sun's JDBC RowSet Implementations download (rowset.jar).
* be available at runtime: by default, a standard JDBC {@code CachedRowSet}
* is used.
* @param sql the SQL query to execute
* @param args arguments to bind to the query
* @param argTypes the SQL types of the arguments
Expand All @@ -897,9 +895,8 @@ <T> List<T> queryForList(String sql, Object[] args, int[] argTypes, Class<T> ele
* <p>The results will be mapped to an SqlRowSet which holds the data in a
* disconnected fashion. This wrapper will translate any SQLExceptions thrown.
* <p>Note that, for the default implementation, JDBC RowSet support needs to
* be available at runtime: by default, Sun's {@code com.sun.rowset.CachedRowSetImpl}
* class is used, which is part of JDK 1.5+ and also available separately as part of
* Sun's JDBC RowSet Implementations download (rowset.jar).
* be available at runtime: by default, a standard JDBC {@code CachedRowSet}
* is used.
* @param sql the SQL query to execute
* @param args arguments to bind to the query
* (leaving it to the PreparedStatement to guess the corresponding SQL type);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -79,7 +79,7 @@ protected SqlRowSet createSqlRowSet(ResultSet rs) throws SQLException {
/**
* Create a new {@link CachedRowSet} instance, to be populated by
* the {@code createSqlRowSet} implementation.
* <p>The default implementation uses JDBC 4.1's {@link RowSetFactory}.
* <p>The default implementation uses JDBC's {@link RowSetFactory}.
* @return a new CachedRowSet instance
* @throws SQLException if thrown by JDBC methods
* @see #createSqlRowSet
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -449,9 +449,8 @@ <T> List<T> queryForList(String sql, Map<String, ?> paramMap, Class<T> elementTy
* <p>The results will be mapped to an SqlRowSet which holds the data in a
* disconnected fashion. This wrapper will translate any SQLExceptions thrown.
* <p>Note that, for the default implementation, JDBC RowSet support needs to
* be available at runtime: by default, Sun's {@code com.sun.rowset.CachedRowSetImpl}
* class is used, which is part of JDK 1.5+ and also available separately as part of
* Sun's JDBC RowSet Implementations download (rowset.jar).
* be available at runtime: by default, a standard JDBC {@code CachedRowSet}
* is used.
* @param sql the SQL query to execute
* @param paramSource container of arguments to bind to the query
* @return an SqlRowSet representation (possibly a wrapper around a
Expand All @@ -469,9 +468,8 @@ <T> List<T> queryForList(String sql, Map<String, ?> paramMap, Class<T> elementTy
* <p>The results will be mapped to an SqlRowSet which holds the data in a
* disconnected fashion. This wrapper will translate any SQLExceptions thrown.
* <p>Note that, for the default implementation, JDBC RowSet support needs to
* be available at runtime: by default, Sun's {@code com.sun.rowset.CachedRowSetImpl}
* class is used, which is part of JDK 1.5+ and also available separately as part of
* Sun's JDBC RowSet Implementations download (rowset.jar).
* be available at runtime: by default, a standard JDBC {@code CachedRowSet}
* is used.
* @param sql the SQL query to execute
* @param paramMap map of parameters to bind to the query
* (leaving it to the PreparedStatement to guess the corresponding SQL type)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,14 @@
/**
* Implementation of the
* {@link org.springframework.transaction.interceptor.TransactionAttributeSource}
* interface for working with transaction metadata in JDK 1.5+ annotation format.
* interface for working with transaction metadata from annotations.
*
* <p>This class reads Spring's JDK 1.5+ {@link Transactional} annotation and
* <p>This class reads Spring's {@link Transactional @Transactional} annotation and
* exposes corresponding transaction attributes to Spring's transaction infrastructure.
* Also supports JTA 1.2's {@link jakarta.transaction.Transactional} and EJB3's
* Also supports JTA's {@link jakarta.transaction.Transactional} and EJB's
* {@link jakarta.ejb.TransactionAttribute} annotation (if present).
* This class may also serve as base class for a custom TransactionAttributeSource,
*
* <p>This class may also serve as base class for a custom TransactionAttributeSource,
* or get customized through {@link TransactionAnnotationParser} strategies.
*
* @author Colin Sampaleanu
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

package org.springframework.web.servlet.view;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
Expand Down Expand Up @@ -49,8 +47,9 @@
import static org.mockito.Mockito.verify;

/**
* Tests for redirect view, and query string construction.
* Doesn't test URL encoding, although it does check that it's called.
* Tests for redirect view and query string construction.
*
* <p>Doesn't test URL encoding, although it does check that it's called.
*
* @author Rod Johnson
* @author Juergen Hoeller
Expand All @@ -61,28 +60,24 @@
*/
class RedirectViewTests {

private MockHttpServletRequest request;
private MockHttpServletRequest request = new MockHttpServletRequest();

private MockHttpServletResponse response;
private MockHttpServletResponse response = new MockHttpServletResponse();


@BeforeEach
void setUp() {
this.request = new MockHttpServletRequest();
this.request.setContextPath("/context");
this.request.setCharacterEncoding(WebUtils.DEFAULT_CHARACTER_ENCODING);
this.request.setAttribute(DispatcherServlet.OUTPUT_FLASH_MAP_ATTRIBUTE, new FlashMap());
this.request.setAttribute(DispatcherServlet.FLASH_MAP_MANAGER_ATTRIBUTE, new SessionFlashMapManager());
this.response = new MockHttpServletResponse();

}


@Test
void noUrlSet() {
RedirectView rv = new RedirectView();
assertThatIllegalArgumentException().isThrownBy(
rv::afterPropertiesSet);
assertThatIllegalArgumentException().isThrownBy(rv::afterPropertiesSet);
}

@Test
Expand Down Expand Up @@ -175,7 +170,6 @@ void updateTargetUrl() throws Exception {
verify(mockProcessor).processUrl(request, "/path");
}


@Test
void updateTargetUrlWithContextLoader() throws Exception {
StaticWebApplicationContext wac = new StaticWebApplicationContext();
Expand Down Expand Up @@ -214,7 +208,6 @@ public void remoteHost() {
assertThat(rv.isRemoteHost("https://url.somewhere.com")).isFalse();
assertThat(rv.isRemoteHost("/path")).isFalse();
assertThat(rv.isRemoteHost("http://somewhereelse.example")).isTrue();

}

@Test // SPR-16752
Expand Down Expand Up @@ -247,16 +240,15 @@ void singleParam() throws Exception {
String url = "https://url.somewhere.com";
String key = "foo";
String val = "bar";
Map<String, String> model = new HashMap<>();
model.put(key, val);
Map<String, String> model = Map.of(key, val);
String expectedUrlForEncoding = url + "?" + key + "=" + val;
doTest(model, url, false, expectedUrlForEncoding);
}

@Test
void singleParamWithoutExposingModelAttributes() throws Exception {
String url = "https://url.somewhere.com";
Map<String, String> model = Collections.singletonMap("foo", "bar");
Map<String, String> model = Map.of("foo", "bar");

TestRedirectView rv = new TestRedirectView(url, false, model);
rv.setExposeModelAttributes(false);
Expand Down Expand Up @@ -289,56 +281,31 @@ void twoParams() throws Exception {
String val = "bar";
String key2 = "thisIsKey2";
String val2 = "andThisIsVal2";
Map<String, String> model = new HashMap<>();
Map<String, String> model = new LinkedHashMap<>();
model.put(key, val);
model.put(key2, val2);
try {
String expectedUrlForEncoding = url + "?" + key + "=" + val + "&" + key2 + "=" + val2;
doTest(model, url, false, expectedUrlForEncoding);
}
catch (AssertionError err) {
// OK, so it's the other order... probably on Sun JDK 1.6 or IBM JDK 1.5
String expectedUrlForEncoding = url + "?" + key2 + "=" + val2 + "&" + key + "=" + val;
doTest(model, url, false, expectedUrlForEncoding);
}
String expectedUrlForEncoding = url + "?" + key + "=" + val + "&" + key2 + "=" + val2;
doTest(model, url, false, expectedUrlForEncoding);
}

@Test
void arrayParam() throws Exception {
String url = "https://url.somewhere.com";
String key = "foo";
String[] val = new String[] {"bar", "baz"};
Map<String, String[]> model = new HashMap<>();
model.put(key, val);
try {
String expectedUrlForEncoding = url + "?" + key + "=" + val[0] + "&" + key + "=" + val[1];
doTest(model, url, false, expectedUrlForEncoding);
}
catch (AssertionError err) {
// OK, so it's the other order... probably on Sun JDK 1.6 or IBM JDK 1.5
String expectedUrlForEncoding = url + "?" + key + "=" + val[1] + "&" + key + "=" + val[0];
doTest(model, url, false, expectedUrlForEncoding);
}
Map<String, String[]> model = Map.of(key, val);
String expectedUrlForEncoding = url + "?" + key + "=" + val[0] + "&" + key + "=" + val[1];
doTest(model, url, false, expectedUrlForEncoding);
}

@Test
void collectionParam() throws Exception {
String url = "https://url.somewhere.com";
String key = "foo";
List<String> val = new ArrayList<>();
val.add("bar");
val.add("baz");
Map<String, List<String>> model = new HashMap<>();
model.put(key, val);
try {
String expectedUrlForEncoding = url + "?" + key + "=" + val.get(0) + "&" + key + "=" + val.get(1);
doTest(model, url, false, expectedUrlForEncoding);
}
catch (AssertionError err) {
// OK, so it's the other order... probably on Sun JDK 1.6 or IBM JDK 1.5
String expectedUrlForEncoding = url + "?" + key + "=" + val.get(1) + "&" + key + "=" + val.get(0);
doTest(model, url, false, expectedUrlForEncoding);
}
List<String> val = List.of("bar", "baz");
Map<String, List<String>> model = Map.of(key, val);
String expectedUrlForEncoding = url + "?" + key + "=" + val.get(0) + "&" + key + "=" + val.get(1);
doTest(model, url, false, expectedUrlForEncoding);
}

@Test
Expand Down

0 comments on commit e1b1435

Please sign in to comment.