From b697dc5bfc9017ffd726007ed122bc4e1290eace Mon Sep 17 00:00:00 2001 From: jvoisin Date: Wed, 5 Jun 2019 23:40:10 +0200 Subject: [PATCH] An other batch of LGTM-found issues --- .../airsonic/player/controller/AccessDeniedController.java | 2 +- .../player/controller/PodcastReceiverAdminController.java | 4 ++-- .../player/security/CustomUserDetailsContextMapper.java | 2 +- .../org/airsonic/player/service/upnp/AlbumUpnpProcessor.java | 3 +++ .../src/main/java/org/airsonic/player/util/HttpRange.java | 2 +- 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/airsonic-main/src/main/java/org/airsonic/player/controller/AccessDeniedController.java b/airsonic-main/src/main/java/org/airsonic/player/controller/AccessDeniedController.java index c6156282..2229a041 100644 --- a/airsonic-main/src/main/java/org/airsonic/player/controller/AccessDeniedController.java +++ b/airsonic-main/src/main/java/org/airsonic/player/controller/AccessDeniedController.java @@ -21,7 +21,7 @@ public class AccessDeniedController { @RequestMapping(method = {RequestMethod.GET}) public ModelAndView accessDenied(HttpServletRequest request, HttpServletResponse response) { - LOG.info("The IP {0} tried to access the forbidden url {1}.", request.getRemoteAddr(), request.getRequestURL()); + LOG.info("The IP {} tried to access the forbidden url {}.", request.getRemoteAddr(), request.getRequestURL()); return new ModelAndView("accessDenied"); } diff --git a/airsonic-main/src/main/java/org/airsonic/player/controller/PodcastReceiverAdminController.java b/airsonic-main/src/main/java/org/airsonic/player/controller/PodcastReceiverAdminController.java index 65354639..f5178e80 100644 --- a/airsonic-main/src/main/java/org/airsonic/player/controller/PodcastReceiverAdminController.java +++ b/airsonic-main/src/main/java/org/airsonic/player/controller/PodcastReceiverAdminController.java @@ -56,11 +56,11 @@ public class PodcastReceiverAdminController { podcastService.createChannel(url); return new ModelAndView(new RedirectView("podcastChannels.view")); } - if (request.getParameter("downloadEpisode") != null) { + if (request.getParameter("downloadEpisode") != null && channelId != null) { download(StringUtil.parseInts(request.getParameter("downloadEpisode"))); return new ModelAndView(new RedirectView("podcastChannel.view?id=" + channelId)); } - if (request.getParameter("deleteChannel") != null) { + if (request.getParameter("deleteChannel") != null && channelId != null) { podcastService.deleteChannel(channelId); return new ModelAndView(new RedirectView("podcastChannels.view")); } diff --git a/airsonic-main/src/main/java/org/airsonic/player/security/CustomUserDetailsContextMapper.java b/airsonic-main/src/main/java/org/airsonic/player/security/CustomUserDetailsContextMapper.java index 0272144e..6bfa0582 100644 --- a/airsonic-main/src/main/java/org/airsonic/player/security/CustomUserDetailsContextMapper.java +++ b/airsonic-main/src/main/java/org/airsonic/player/security/CustomUserDetailsContextMapper.java @@ -110,7 +110,7 @@ public class CustomUserDetailsContextMapper implements UserDetailsContextMapper public void mapUserToContext(UserDetails user, DirContextAdapter ctx) { throw new UnsupportedOperationException( - "LdapUserDetailsMapper only supports reading from a context. Please" + "LdapUserDetailsMapper only supports reading from a context. Please " + "use a subclass if mapUserToContext() is required."); } diff --git a/airsonic-main/src/main/java/org/airsonic/player/service/upnp/AlbumUpnpProcessor.java b/airsonic-main/src/main/java/org/airsonic/player/service/upnp/AlbumUpnpProcessor.java index 9b28a437..5ffe9737 100644 --- a/airsonic-main/src/main/java/org/airsonic/player/service/upnp/AlbumUpnpProcessor.java +++ b/airsonic-main/src/main/java/org/airsonic/player/service/upnp/AlbumUpnpProcessor.java @@ -38,6 +38,7 @@ import org.springframework.web.util.UriComponentsBuilder; import java.net.URI; import java.net.URISyntaxException; +import java.util.ArrayList; import java.util.List; /** @@ -120,6 +121,8 @@ public class AlbumUpnpProcessor extends UpnpContentProcessor albumList = ap.getChildren(ap.getItemById(album.getComment().replaceAll(ALL_BY_ARTIST + "_", ""))); } else if (album.getComment().equalsIgnoreCase(ALL_RECENT)) { albumList = getDispatcher().getRecentAlbumProcessor().getAllItems(); + } else { + albumList = new ArrayList<>(); } for (Album a: albumList) { if (a.getId() != -1) { diff --git a/airsonic-main/src/main/java/org/airsonic/player/util/HttpRange.java b/airsonic-main/src/main/java/org/airsonic/player/util/HttpRange.java index 5aae4456..29ca2c4b 100644 --- a/airsonic-main/src/main/java/org/airsonic/player/util/HttpRange.java +++ b/airsonic-main/src/main/java/org/airsonic/player/util/HttpRange.java @@ -56,7 +56,7 @@ public class HttpRange { String firstString = matcher.group(1); String lastString = StringUtils.trimToNull(matcher.group(2)); - Long first = Long.parseLong(firstString); + long first = Long.parseLong(firstString); Long last = lastString == null ? null : Long.parseLong(lastString); if (last != null && first > last) {