1
1
/****************************************************************************
2
- * Copyright 2016, Optimizely, Inc. and contributors *
2
+ * Copyright 2016-2017 , Optimizely, Inc. and contributors *
3
3
* *
4
4
* Licensed under the Apache License, Version 2.0 (the "License"); *
5
5
* you may not use this file except in compliance with the License. *
30
30
import java .util .concurrent .TimeUnit ;
31
31
32
32
/**
33
- * Functionality common to all clients
34
- * @hide
33
+ * Functionality common to all clients using http connections
35
34
*/
36
35
public class Client {
37
36
@@ -46,7 +45,6 @@ public class Client {
46
45
*
47
46
* @param optlyStorage an instance of {@link OptlyStorage}
48
47
* @param logger an instance of {@link Logger}
49
- * @hide
50
48
*/
51
49
public Client (@ NonNull OptlyStorage optlyStorage , @ NonNull Logger logger ) {
52
50
this .optlyStorage = optlyStorage ;
@@ -58,7 +56,6 @@ public Client(@NonNull OptlyStorage optlyStorage, @NonNull Logger logger) {
58
56
*
59
57
* @param url a {@link URL} instance
60
58
* @return an open {@link HttpURLConnection}
61
- * @hide
62
59
*/
63
60
@ Nullable
64
61
public HttpURLConnection openConnection (URL url ) {
@@ -74,7 +71,6 @@ public HttpURLConnection openConnection(URL url) {
74
71
* Adds a if-modified-since header to the open {@link URLConnection} if this value is
75
72
* stored in {@link OptlyStorage}.
76
73
* @param urlConnection an open {@link URLConnection}
77
- * @hide
78
74
*/
79
75
public void setIfModifiedSince (@ NonNull URLConnection urlConnection ) {
80
76
long lastModified = optlyStorage .getLong (LAST_MODIFIED_HEADER_KEY , 0 );
@@ -87,7 +83,6 @@ public void setIfModifiedSince(@NonNull URLConnection urlConnection) {
87
83
* Retrieves the last-modified head from a {@link URLConnection} and saves it
88
84
* in {@link OptlyStorage}.
89
85
* @param urlConnection a {@link URLConnection} instance
90
- * @hide
91
86
*/
92
87
public void saveLastModified (@ NonNull URLConnection urlConnection ) {
93
88
long lastModified = urlConnection .getLastModified ();
@@ -112,7 +107,12 @@ public String readStream(@NonNull URLConnection urlConnection) {
112
107
finally {
113
108
if (scanner != null ) {
114
109
// We assume that closing the scanner will close the associated input stream.
115
- scanner .close ();
110
+ try {
111
+ scanner .close ();
112
+ }
113
+ catch (Exception e ) {
114
+ logger .error ("Problem with closing the scanner on a input stream" , e );
115
+ }
116
116
}
117
117
}
118
118
}
0 commit comments