Skip to content

Commit 3072f65

Browse files
committed
Fix for #36
- Prevent NPE
1 parent 1b2840a commit 3072f65

File tree

4 files changed

+13
-6
lines changed

4 files changed

+13
-6
lines changed

CHANGELOG.txt

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
1.3.4 - 22 Aptril 2021
1+
1.3.5 - 22 April 2021
2+
- Fix for #36
3+
4+
1.3.4 - 22 April 2021
25
- Updated to browscap 6000043.
36
- Updated unit tests accordingly (new bots mostly).
47

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Add this to the dependencies in your pom.xml.
4242
<dependency>
4343
<groupId>com.blueconic</groupId>
4444
<artifactId>browscap-java</artifactId>
45-
<version>1.3.4</version>
45+
<version>1.3.5</version>
4646
</dependency>
4747
```
4848

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<groupId>com.blueconic</groupId>
55
<artifactId>browscap-java</artifactId>
66
<packaging>jar</packaging>
7-
<version>1.3.4</version>
7+
<version>1.3.5</version>
88
<name>browscap-java</name>
99
<description>A blazingly fast and memory efficient Java client on top of the BrowsCap CSV source files.</description>
1010

src/main/java/com/blueconic/browscap/impl/UserAgentParserImpl.java

+7-3
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class UserAgentParserImpl implements UserAgentParser {
2929
"rv:", "build", "bot", "like gecko", "applewebkit", "trident", "mozilla", "windows nt 4", "windows nt 5.0",
3030
"windows nt 5.1", "windows nt 5.2", "windows nt 6.0", "windows nt 6.1", "windows nt 6.2", "windows nt 6.3",
3131
"windows nt 10.0", "android?4.0", "android?4.1", "android?4.2", "android?4.3", "android?4.4", "android?2.3",
32-
"android?5"};
32+
"android?5"};
3333

3434
// Common prefixes to filter irrelevant rules and speed up processing
3535
static final String[] FILTER_PREFIXES = {"mozilla/5.0", "mozilla/4"};
@@ -64,6 +64,9 @@ class UserAgentParserImpl implements UserAgentParser {
6464
*/
6565
@Override
6666
public Capabilities parse(final String userAgent) {
67+
if (userAgent == null || userAgent.length() == 0) {
68+
return myDefaultCapabilities;
69+
}
6770

6871
final SearchableString searchString = myDomain.getSearchableString(userAgent.toLowerCase());
6972

@@ -110,9 +113,10 @@ Filter[] buildFilters() {
110113
for (final String pattern : FILTER_PREFIXES) {
111114
result.add(createPrefixFilter(pattern));
112115
}
113-
116+
114117
// Build filters for specific contains constraints
115-
final List<Filter> commonFilters = Stream.of(COMMON).parallel().map(this::createContainsFilter).collect(toList());
118+
final List<Filter> commonFilters =
119+
Stream.of(COMMON).parallel().map(this::createContainsFilter).collect(toList());
116120
result.addAll(commonFilters);
117121

118122
return result.toArray(new Filter[0]);

0 commit comments

Comments
 (0)