Skip to content

Commit 9b86fc5

Browse files
committed
Explicit lambda argument types
1 parent c588915 commit 9b86fc5

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/main/java/org/libj/net/Downloads.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public static HttpURLConnection downloadFile(final URL fromUrl, final File toFil
141141
* @throws IllegalArgumentException If the {@code connectTimeout} or {@code readTimeout} parameter is negative.
142142
*/
143143
public static HttpURLConnection downloadFile(final URL fromUrl, final File toFile, final int connectTimeout, final int readTimeout, final boolean followRedirects, CopyOption ... options) throws IOException {
144-
final HttpURLConnection connection = (HttpURLConnection)(followRedirects ? URLConnections.checkFollowRedirect(fromUrl.openConnection(), c -> beforeDownloadFile(c, connectTimeout, readTimeout, toFile)) : fromUrl.openConnection());
144+
final HttpURLConnection connection = (HttpURLConnection)(followRedirects ? URLConnections.checkFollowRedirect(fromUrl.openConnection(), (final HttpURLConnection c) -> beforeDownloadFile(c, connectTimeout, readTimeout, toFile)) : fromUrl.openConnection());
145145
try {
146146
if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) {
147147
try (final InputStream in = connection.getInputStream()) {

src/main/java/org/libj/net/HTTP.java

+8-8
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@
2020
import java.io.InputStream;
2121
import java.io.OutputStreamWriter;
2222
import java.io.UnsupportedEncodingException;
23+
import java.net.HttpURLConnection;
2324
import java.net.MalformedURLException;
2425
import java.net.URL;
2526
import java.net.URLConnection;
2627
import java.net.URLEncoder;
2728
import java.util.Iterator;
2829
import java.util.List;
2930
import java.util.Map;
30-
import java.util.Properties;
3131

3232
/**
3333
* Utility functions pertaining to the {@link HTTP} protocol.
@@ -77,7 +77,7 @@ public static InputStream getAsStream(final String url, final Map<String,String[
7777
* @throws UnsupportedEncodingException If the provided charset is not supported.
7878
*/
7979
public static InputStream getAsStream(final String url, final Map<String,String[]> parameters, final String charset) throws IOException, UnsupportedEncodingException {
80-
return URLConnections.checkFollowRedirect(get(url, parameters, charset).openConnection(), c -> c.setUseCaches(false)).getInputStream();
80+
return URLConnections.checkFollowRedirect(get(url, parameters, charset).openConnection(), (final HttpURLConnection c) -> c.setUseCaches(false)).getInputStream();
8181
}
8282

8383
/**
@@ -92,7 +92,7 @@ public static InputStream getAsStream(final String url, final Map<String,String[
9292
* @throws UnsupportedEncodingException If the provided charset is not supported.
9393
*/
9494
public static InputStream getAsStream(final URL url) throws IOException, UnsupportedEncodingException {
95-
return URLConnections.checkFollowRedirect(url.openConnection(), c -> c.setUseCaches(false)).getInputStream();
95+
return URLConnections.checkFollowRedirect(url.openConnection(), (final HttpURLConnection c) -> c.setUseCaches(false)).getInputStream();
9696
}
9797

9898
/**
@@ -139,7 +139,7 @@ public static InputStream postAsStream(final URL url, final Map<String,String[]>
139139
* @throws IOException If an I/O error has occurred.
140140
* @throws NullPointerException If {@code url} is null.
141141
*/
142-
public static InputStream postAsStream(final URL url, final Map<String,String[]> parameters, final Properties properties) throws IOException { // FIXME: Should switch Properties to HashMap, and also need to make it case-insensitive?
142+
public static InputStream postAsStream(final URL url, final Map<String,String[]> parameters, final Map<String,String> properties) throws IOException {
143143
return postAsStream(url, parameters, properties, null);
144144
}
145145

@@ -156,8 +156,8 @@ public static InputStream postAsStream(final URL url, final Map<String,String[]>
156156
* @throws IOException If an I/O error has occurred.
157157
* @throws NullPointerException If {@code url} is null.
158158
*/
159-
public static InputStream postAsStream(final URL url, final Map<String,String[]> parameters, final Properties properties, final List<String> cookies) throws IOException { // FIXME: Should switch Properties to HashMap, and also need to make it case-insensitive?
160-
String charset = properties != null ? properties.getProperty("accept-charset") : null;
159+
public static InputStream postAsStream(final URL url, final Map<String,String[]> parameters, final Map<String,String> properties, final List<String> cookies) throws IOException {
160+
String charset = properties != null ? properties.get("accept-charset") : null;
161161
if (charset == null)
162162
charset = "UTF-8";
163163

@@ -167,8 +167,8 @@ public static InputStream postAsStream(final URL url, final Map<String,String[]>
167167
urlConnection.setDoOutput(true); // Triggers POST
168168
// urlConnection.setRequestProperty("content-type", "application/x-www-form-urlencoded");
169169
if (properties != null && properties.size() > 0)
170-
for (final Map.Entry<Object,Object> property : properties.entrySet()) // [S]
171-
urlConnection.setRequestProperty((String)property.getKey(), (String)property.getValue());
170+
for (final Map.Entry<String,String> property : properties.entrySet()) // [S]
171+
urlConnection.setRequestProperty(property.getKey(), property.getValue());
172172

173173
if (cookies != null) {
174174
final Map.Entry<String,String> cookie = Cookies.createCookieHeader(cookies);

0 commit comments

Comments
 (0)