Skip to content
This repository was archived by the owner on Jun 7, 2022. It is now read-only.

Commit 85df767

Browse files
author
Tarek
committed
fixed nullpointerexception bug
1 parent 716edd1 commit 85df767

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

cloudnet-cord/cloudnet-cloudflare/src/main/java/de/dytanic/cloudnet/cloudflare/CloudFlareService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public boolean bootstrap(Map<String, SimpledWrapperInfo> wrapperInfoMap, Map<Str
7272
ProxyGroup proxyGroup = groups.get(cloudFlareProxyGroup.getName());
7373
for (String wrapper : proxyGroup.getWrapper())
7474
{
75-
if (!cloudFlareDatabase.contains(cloudFlareConfig, wrapper)) //TODO
75+
if (!cloudFlareDatabase.contains(cloudFlareConfig, wrapper))
7676
{
7777
String host = wrapperInfoMap.get(wrapper).getHostName();
7878
DNSRecord dnsRecord = new DefaultDNSRecord(DNSType.A, wrapper + "." + cloudFlareConfig.getDomainName(), host, new Document().obj());

cloudnet-cord/cloudnet-cloudflare/src/main/java/de/dytanic/cloudnet/cloudflare/database/CloudFlareDatabase.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
import de.dytanic.cloudnet.lib.MultiValue;
1212
import de.dytanic.cloudnet.lib.database.Database;
1313
import de.dytanic.cloudnet.lib.database.DatabaseDocument;
14-
import de.dytanic.cloudnet.lib.utility.Acceptable;
15-
import de.dytanic.cloudnet.lib.utility.CollectionWrapper;
1614
import de.dytanic.cloudnet.lib.utility.MapWrapper;
1715
import de.dytanic.cloudnet.lib.utility.Return;
1816
import de.dytanic.cloudnet.lib.utility.document.Document;
@@ -56,17 +54,33 @@ public void putPostResponse(MultiValue<PostResponse, String> postResponse)
5654
public boolean contains(CloudFlareConfig cloudFlareConfig, String wrapper)
5755
{
5856
Document document = database.getDocument(CLOUDFLARE_CACHE);
57+
58+
/*
5959
Map<String, MultiValue<PostResponse, String>> responses = document.getObject("requests", new TypeToken<Map<String, MultiValue<PostResponse, String>>>() {
6060
}.getType());
61+
*/
6162

63+
/*
6264
return CollectionWrapper.filter(responses.values(), new Acceptable<MultiValue<PostResponse, String>>() {
6365
@Override
6466
public boolean isAccepted(MultiValue<PostResponse, String> value)
6567
{
6668
return value.getSecond().equalsIgnoreCase(wrapper) && value.getFirst().getCloudFlareConfig().getDomainName().equalsIgnoreCase(cloudFlareConfig.getDomainName());
6769
}
6870
}) != null;
71+
*/
72+
73+
for (String key : document.keys())
74+
if (!key.equalsIgnoreCase(Database.UNIQUE_NAME_KEY))
75+
{
76+
MultiValue<PostResponse, String> value = document.getObject(key, new TypeToken<MultiValue<PostResponse, String>>() {
77+
}.getType());
78+
79+
if (value.getSecond().equalsIgnoreCase(wrapper) && value.getFirst().getCloudFlareConfig().getDomainName().equalsIgnoreCase(cloudFlareConfig.getDomainName()))
80+
return true;
81+
}
6982

83+
return false;
7084
//return document.contains(wrapper);
7185
}
7286

0 commit comments

Comments
 (0)