Skip to content

Commit 640c8ff

Browse files
committed
Polishing
1 parent d52d9fd commit 640c8ff

File tree

14 files changed

+85
-99
lines changed

14 files changed

+85
-99
lines changed

spring-core/src/main/java/org/springframework/core/io/ByteArrayResource.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,15 @@ public class ByteArrayResource extends AbstractResource {
4747

4848

4949
/**
50-
* Create a new ByteArrayResource.
50+
* Create a new {@code ByteArrayResource}.
5151
* @param byteArray the byte array to wrap
5252
*/
5353
public ByteArrayResource(byte[] byteArray) {
5454
this(byteArray, "resource loaded from byte array");
5555
}
5656

5757
/**
58-
* Create a new ByteArrayResource.
58+
* Create a new {@code ByteArrayResource} with a description.
5959
* @param byteArray the byte array to wrap
6060
* @param description where the byte array comes from
6161
*/
@@ -65,14 +65,14 @@ public ByteArrayResource(byte[] byteArray, String description) {
6565
this.description = (description != null ? description : "");
6666
}
6767

68+
6869
/**
6970
* Return the underlying byte array.
7071
*/
7172
public final byte[] getByteArray() {
7273
return this.byteArray;
7374
}
7475

75-
7676
/**
7777
* This implementation always returns {@code true}.
7878
*/

spring-jdbc/src/main/java/org/springframework/jdbc/core/JdbcOperations.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -755,7 +755,7 @@ <T>List<T> queryForList(String sql, Object[] args, int[] argTypes, Class<T> elem
755755
* list of arguments to bind to the query, expecting a SqlRowSet.
756756
* <p>The results will be mapped to an SqlRowSet which holds the data in a
757757
* disconnected fashion. This wrapper will translate any SQLExceptions thrown.
758-
* <p>Note that that, for the default implementation, JDBC RowSet support needs to
758+
* <p>Note that, for the default implementation, JDBC RowSet support needs to
759759
* be available at runtime: by default, Sun's {@code com.sun.rowset.CachedRowSetImpl}
760760
* class is used, which is part of JDK 1.5+ and also available separately as part of
761761
* Sun's JDBC RowSet Implementations download (rowset.jar).
@@ -778,7 +778,7 @@ <T>List<T> queryForList(String sql, Object[] args, int[] argTypes, Class<T> elem
778778
* list of arguments to bind to the query, expecting a SqlRowSet.
779779
* <p>The results will be mapped to an SqlRowSet which holds the data in a
780780
* disconnected fashion. This wrapper will translate any SQLExceptions thrown.
781-
* <p>Note that that, for the default implementation, JDBC RowSet support needs to
781+
* <p>Note that, for the default implementation, JDBC RowSet support needs to
782782
* be available at runtime: by default, Sun's {@code com.sun.rowset.CachedRowSetImpl}
783783
* class is used, which is part of JDK 1.5+ and also available separately as part of
784784
* Sun's JDBC RowSet Implementations download (rowset.jar).
@@ -882,7 +882,7 @@ <T>List<T> queryForList(String sql, Object[] args, int[] argTypes, Class<T> elem
882882
* @param batchArgs the List of Object arrays containing the batch of arguments for the query
883883
* @return an array containing the numbers of rows affected by each update in the batch
884884
*/
885-
public int[] batchUpdate(String sql, List<Object[]> batchArgs) throws DataAccessException;
885+
int[] batchUpdate(String sql, List<Object[]> batchArgs) throws DataAccessException;
886886

887887
/**
888888
* Execute a batch using the supplied SQL statement with the batch of supplied arguments.
@@ -892,7 +892,7 @@ <T>List<T> queryForList(String sql, Object[] args, int[] argTypes, Class<T> elem
892892
* (constants from {@code java.sql.Types})
893893
* @return an array containing the numbers of rows affected by each update in the batch
894894
*/
895-
public int[] batchUpdate(String sql, List<Object[]> batchArgs, int[] argTypes) throws DataAccessException;
895+
int[] batchUpdate(String sql, List<Object[]> batchArgs, int[] argTypes) throws DataAccessException;
896896

897897
/**
898898
* Execute multiple batches using the supplied SQL statement with the collect of supplied arguments.
@@ -905,7 +905,7 @@ <T>List<T> queryForList(String sql, Object[] args, int[] argTypes, Class<T> elem
905905
* @return an array containing for each batch another array containing the numbers of rows affected
906906
* by each update in the batch
907907
*/
908-
public <T> int[][] batchUpdate(String sql, Collection<T> batchArgs, int batchSize,
908+
<T> int[][] batchUpdate(String sql, Collection<T> batchArgs, int batchSize,
909909
ParameterizedPreparedStatementSetter<T> pss) throws DataAccessException;
910910

911911

spring-jdbc/src/main/java/org/springframework/jdbc/core/JdbcTemplate.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,7 @@ public void execute(final String sql) throws DataAccessException {
429429
if (logger.isDebugEnabled()) {
430430
logger.debug("Executing SQL statement [" + sql + "]");
431431
}
432+
432433
class ExecuteStatementCallback implements StatementCallback<Object>, SqlProvider {
433434
@Override
434435
public Object doInStatement(Statement stmt) throws SQLException {
@@ -440,6 +441,7 @@ public String getSql() {
440441
return sql;
441442
}
442443
}
444+
443445
execute(new ExecuteStatementCallback());
444446
}
445447

@@ -450,6 +452,7 @@ public <T> T query(final String sql, final ResultSetExtractor<T> rse) throws Dat
450452
if (logger.isDebugEnabled()) {
451453
logger.debug("Executing SQL query [" + sql + "]");
452454
}
455+
453456
class QueryStatementCallback implements StatementCallback<T>, SqlProvider {
454457
@Override
455458
public T doInStatement(Statement stmt) throws SQLException {
@@ -471,6 +474,7 @@ public String getSql() {
471474
return sql;
472475
}
473476
}
477+
474478
return execute(new QueryStatementCallback());
475479
}
476480

@@ -521,6 +525,7 @@ public int update(final String sql) throws DataAccessException {
521525
if (logger.isDebugEnabled()) {
522526
logger.debug("Executing SQL update [" + sql + "]");
523527
}
528+
524529
class UpdateStatementCallback implements StatementCallback<Integer>, SqlProvider {
525530
@Override
526531
public Integer doInStatement(Statement stmt) throws SQLException {
@@ -535,6 +540,7 @@ public String getSql() {
535540
return sql;
536541
}
537542
}
543+
538544
return execute(new UpdateStatementCallback());
539545
}
540546

spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/NamedParameterBatchUpdateUtils.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -24,30 +24,31 @@
2424
import org.springframework.jdbc.core.JdbcOperations;
2525

2626
/**
27-
* Generic utility methods for working with JDBC batch statements using named parameters. Mainly for internal use
28-
* within the framework.
27+
* Generic utility methods for working with JDBC batch statements using named parameters.
28+
* Mainly for internal use within the framework.
2929
*
3030
* @author Thomas Risberg
31+
* @since 3.0
3132
*/
3233
public class NamedParameterBatchUpdateUtils extends BatchUpdateUtils {
3334

3435
public static int[] executeBatchUpdateWithNamedParameters(final ParsedSql parsedSql,
3536
final SqlParameterSource[] batchArgs, JdbcOperations jdbcOperations) {
37+
3638
if (batchArgs.length <= 0) {
3739
return new int[] {0};
3840
}
41+
3942
String sqlToUse = NamedParameterUtils.substituteNamedParameters(parsedSql, batchArgs[0]);
4043
return jdbcOperations.batchUpdate(
4144
sqlToUse,
4245
new BatchPreparedStatementSetter() {
43-
4446
@Override
4547
public void setValues(PreparedStatement ps, int i) throws SQLException {
4648
Object[] values = NamedParameterUtils.buildValueArray(parsedSql, batchArgs[i], null);
4749
int[] columnTypes = NamedParameterUtils.buildSqlTypeArray(parsedSql, batchArgs[i]);
4850
setStatementParameters(values, ps, columnTypes);
4951
}
50-
5152
@Override
5253
public int getBatchSize() {
5354
return batchArgs.length;

spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/NamedParameterJdbcTemplate.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -331,8 +331,8 @@ public int[] batchUpdate(String sql, Map<String, ?>[] batchValues) {
331331

332332
@Override
333333
public int[] batchUpdate(String sql, SqlParameterSource[] batchArgs) {
334-
ParsedSql parsedSql = getParsedSql(sql);
335-
return NamedParameterBatchUpdateUtils.executeBatchUpdateWithNamedParameters(parsedSql, batchArgs, getJdbcOperations());
334+
return NamedParameterBatchUpdateUtils.executeBatchUpdateWithNamedParameters(
335+
getParsedSql(sql), batchArgs, getJdbcOperations());
336336
}
337337

338338
/**

spring-web/src/test/java/org/springframework/http/HttpRangeTests.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -40,57 +40,57 @@
4040
public class HttpRangeTests {
4141

4242
@Test(expected = IllegalArgumentException.class)
43-
public void invalidFirstPosition() throws Exception {
43+
public void invalidFirstPosition() {
4444
HttpRange.createByteRange(-1);
4545
}
4646

4747
@Test(expected = IllegalArgumentException.class)
48-
public void invalidLastLessThanFirst() throws Exception {
48+
public void invalidLastLessThanFirst() {
4949
HttpRange.createByteRange(10, 9);
5050
}
5151

5252
@Test(expected = IllegalArgumentException.class)
53-
public void invalidSuffixLength() throws Exception {
53+
public void invalidSuffixLength() {
5454
HttpRange.createSuffixRange(-1);
5555
}
5656

5757
@Test
58-
public void byteRange() throws Exception {
58+
public void byteRange() {
5959
HttpRange range = HttpRange.createByteRange(0, 499);
6060
assertEquals(0, range.getRangeStart(1000));
6161
assertEquals(499, range.getRangeEnd(1000));
6262
}
6363

6464
@Test
65-
public void byteRangeWithoutLastPosition() throws Exception {
65+
public void byteRangeWithoutLastPosition() {
6666
HttpRange range = HttpRange.createByteRange(9500);
6767
assertEquals(9500, range.getRangeStart(10000));
6868
assertEquals(9999, range.getRangeEnd(10000));
6969
}
7070

7171
@Test
72-
public void byteRangeOfZeroLength() throws Exception {
72+
public void byteRangeOfZeroLength() {
7373
HttpRange range = HttpRange.createByteRange(9500, 9500);
7474
assertEquals(9500, range.getRangeStart(10000));
7575
assertEquals(9500, range.getRangeEnd(10000));
7676
}
7777

7878
@Test
79-
public void suffixRange() throws Exception {
79+
public void suffixRange() {
8080
HttpRange range = HttpRange.createSuffixRange(500);
8181
assertEquals(500, range.getRangeStart(1000));
8282
assertEquals(999, range.getRangeEnd(1000));
8383
}
8484

8585
@Test
86-
public void suffixRangeShorterThanRepresentation() throws Exception {
86+
public void suffixRangeShorterThanRepresentation() {
8787
HttpRange range = HttpRange.createSuffixRange(500);
8888
assertEquals(0, range.getRangeStart(350));
8989
assertEquals(349, range.getRangeEnd(350));
9090
}
9191

9292
@Test
93-
public void parseRanges() throws Exception {
93+
public void parseRanges() {
9494
List<HttpRange> ranges = HttpRange.parseRanges("bytes=0-0,500-,-1");
9595
assertEquals(3, ranges.size());
9696
assertEquals(0, ranges.get(0).getRangeStart(1000));
@@ -138,8 +138,8 @@ public void toResourceRegionIllegalLength() {
138138

139139
@Test(expected = IllegalArgumentException.class)
140140
@SuppressWarnings("unchecked")
141-
public void toResourceRegionExceptionLength() {
142-
ByteArrayResource resource = mock(ByteArrayResource.class);
141+
public void toResourceRegionExceptionLength() throws IOException {
142+
InputStreamResource resource = mock(InputStreamResource.class);
143143
given(resource.contentLength()).willThrow(IOException.class);
144144
HttpRange range = HttpRange.createByteRange(0, 9);
145145
range.toResourceRegion(resource);

0 commit comments

Comments
 (0)