Skip to content

Commit

Permalink
Fix #23879: NPE when the OSM API doesn't respond
Browse files Browse the repository at this point in the history
Signed-off-by: Taylor Smock <[email protected]>
  • Loading branch information
tsmock committed Aug 26, 2024
1 parent d2853e6 commit ef9120b
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 35 deletions.
15 changes: 0 additions & 15 deletions .github/workflows/ant-release.yml

This file was deleted.

39 changes: 34 additions & 5 deletions .github/workflows/ant.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,48 @@ on:
branches:
- master
- $default-branch
schedule:
- cron: "52 23 * * 2"
workflow_dispatch:

permissions:
id-token: write
attestations: write
contents: write
packages: write
checks: write

jobs:
check-release-needed:
runs-on: ubuntu-latest
outputs:
release_needed: ${{ steps.create_release_needed.outputs.release_needed }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: ${{ (github.repository == 'JOSM/continuos-download' && github.ref_type == 'branch' && github.ref_name == 'master' && github.event_name != 'schedule' && github.event_name != 'pull_request') && '0' || '1' }}

- name: Set release needed
id: create_release_needed
run: |
last_tag=$(git describe --tags --abbrev=0 --always)
release_needed="false"
for file in $(git diff ${last_tag}..HEAD --name-only); do
if [[ $file = "src/"* ]] || [[ $file = "data/*" ]] || [[ $file = "lib/*" ]] || [[ $file = "resources/*" ]] || [[ $file = "images/*" ]]; then
release_needed="true"
break
fi
done
echo "release_needed=$release_needed" >> $GITHUB_OUTPUT
call-workflow:
needs: check-release-needed
strategy:
matrix:
josm-revision: ["", "r14153"]
uses: JOSM/JOSMPluginAction/.github/workflows/ant.yml@v2
josm-revision: ["", "r19044"]
uses: JOSM/JOSMPluginAction/.github/workflows/ant.yml@v3
with:
josm-revision: ${{ matrix.josm-revision }}
perform-revision-tagging: ${{ github.repository == 'JOSM/continuos-download' && github.ref_type == 'branch' && github.ref_name == 'master' && github.event_name != 'schedule' && github.event_name != 'pull_request' && matrix.josm-revision == 'r14153' }}
perform-revision-tagging: ${{ github.repository == 'JOSM/continuos-download' && github.ref_type == 'branch' && github.ref_name == 'master' && github.event_name != 'schedule' && github.event_name != 'pull_request' && matrix.josm-revision == 'r19044' }}
plugin-jar-name: "continuosDownload"
secrets: inherit
permissions:
Expand Down
13 changes: 0 additions & 13 deletions .github/workflows/reports.yaml

This file was deleted.

9 changes: 9 additions & 0 deletions MANIFEST-OLD-VERSIONS.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
7588_Plugin-Url: v1.1.01;https://github.com/Gnonthgol/JOSM-continuos-download/releases/download/v1.1.01/continuosDownload.jar
7636_Plugin-Url: v1.1.02;https://github.com/Gnonthgol/JOSM-continuos-download/releases/download/v1.1.02/continuosDownload.jar
8942_Plugin-Url: v1.2.2;https://github.com/JOSM/JOSM-continuos-download/releases/download/v1.2.2/continuosDownload.jar
10282_Plugin-Url: v1.2.3;https://github.com/JOSM/JOSM-continuos-download/releases/download/v1.2.3/continuosDownload.jar
10580_Plugin-Url: v1.2.4;https://github.com/JOSM/JOSM-continuos-download/releases/download/v1.2.4/continuosDownload.jar
12643_Plugin-Url: v1.2.5;https://github.com/JOSM/JOSM-continuos-download/releases/download/v1.2.5/continuosDownload.jar
12840_Plugin-Url: v1.2.6;https://github.com/JOSM/JOSM-continuos-download/releases/download/v1.2.6/continuosDownload.jar
13927_Plugin-Url: v1.2.8;https://github.com/JOSM/JOSM-continuos-download/releases/download/v1.2.8/continuosDownload.jar
14153_Plugin-URL: v103;https://github.com/JOSM/continuos-download/releases/download/v103/continuosDownload.jar
3 changes: 2 additions & 1 deletion build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<!-- enter the SVN commit message -->
<property name="commit.message" value="Commit message"/>
<!-- enter the *lowest* JOSM version this plugin is currently compatible with -->
<property name="plugin.main.version" value="14153"/>
<property name="plugin.main.version" value="19044"/>

<!-- Configure these properties (replace "..." accordingly).
See https://josm.openstreetmap.de/wiki/DevelopersGuide/DevelopingPlugins
Expand All @@ -26,6 +26,7 @@
<attribute name="12643_Plugin-Url" value="v1.2.5;https://github.com/JOSM/JOSM-continuos-download/releases/download/v1.2.5/continuosDownload.jar" />
<attribute name="12840_Plugin-Url" value="v1.2.6;https://github.com/JOSM/JOSM-continuos-download/releases/download/v1.2.6/continuosDownload.jar" />
<attribute name="13927_Plugin-Url" value="v1.2.8;https://github.com/JOSM/JOSM-continuos-download/releases/download/v1.2.8/continuosDownload.jar" />
<attribute name="14153_Plugin-Url" value="v103;https://github.com/JOSM/JOSM-continuos-download/releases/download/v103/continuosDownload.jar" />
</manifest>
</target>

Expand Down
45 changes: 45 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.openstreetmap.josm.plugins</groupId>
<artifactId>plugin-root</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>continuosDownload</artifactId>

<url>${plugin.link}</url>
<developers>
<developer>
<id>Gnonthgol</id>
</developer>
</developers>
<properties>
<plugin.src.dir>src</plugin.src.dir>
<plugin.main.version>19044</plugin.main.version>
<plugin.author>Gnonthgol; JOSM developers</plugin.author>
<plugin.class>org.openstreetmap.josm.plugins.continuosDownload.DownloadPlugin</plugin.class>
<plugin.description>Downloads new data when you pan/zoom</plugin.description>
<plugin.icon>images/continuous-download.png</plugin.icon>
<plugin.link>https://github.com/JOSM/JOSM-continuos-download</plugin.link>
<plugin.canloadatruntime>true</plugin.canloadatruntime>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestEntries>
<Plugin-Link>${plugin.link}</Plugin-Link>
<Plugin-Icon>${plugin.icon}</Plugin-Icon>
<Plugin-Canloadatruntime>${plugin.canloadatruntime}</Plugin-Canloadatruntime>
</manifestEntries>
<manifestFile>MANIFEST-OLD-VERSIONS.MF</manifestFile>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ public AbstractDownloadStrategy getStrat() {
* @param exception the exception to handle
*/
private void handleException(final Exception exception) {
if (exception instanceof OsmApiException && ((OsmApiException) exception).getErrorHeader().contains("requested too many")) {
if (exception instanceof OsmApiException && ((OsmApiException) exception).getErrorHeader() != null &&
((OsmApiException) exception).getErrorHeader().contains("requested too many")) {
this.active = false;
GuiHelper.runInEDT(() -> this.menuItem.setSelected(false));
final ThreadPoolExecutor executor = (ThreadPoolExecutor) worker;
Expand Down

0 comments on commit ef9120b

Please sign in to comment.