Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OkHttpEngine: close catching Exception #873

Merged
merged 1 commit into from
Sep 8, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions vtm-http/src/org/oscim/tiling/source/OkHttpEngine.java
Original file line number Diff line number Diff line change
@@ -1,7 1,7 @@
/*
* Copyright 2014 Charles Greb
* Copyright 2014 Hannes Janetzek
* Copyright 2017 devemux86
* Copyright 2017-2021 devemux86
* Copyright 2017 Mathieu De Brito
*
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
Expand All @@ -19,8 19,10 @@
*/
package org.oscim.tiling.source;

import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import org.oscim.core.Tile;
import org.oscim.utils.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -31,10 33,6 @@
import java.net.URL;
import java.util.Map.Entry;

import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;

public class OkHttpEngine implements HttpEngine {

private static final Logger log = LoggerFactory.getLogger(OkHttpEngine.class);
Expand Down Expand Up @@ -100,7 98,11 @@ public void close() {
if (mInputStream == null)
return;

IOUtils.closeQuietly(mInputStream);
try {
mInputStream.close();
} catch (Exception e) {
log.error(e.getMessage(), e);
}
mInputStream = null;
}

Expand All @@ -117,9 119,7 @@ public void setCache(OutputStream os) {

@Override
public boolean requestCompleted(boolean success) {
IOUtils.closeQuietly(mInputStream);
mInputStream = null;

close();
return success;
}
}