Skip to content

Commit

Permalink
Make MapToolServer's ID explicitly nullable
Browse files Browse the repository at this point in the history
ServiceAnnouncer requires a non-null String, but an empty server ID is
not well-formed so a ServiceAnnouncer shouldn't be created.

This was previously handled by MapToolServer being passed null config
and the absence of a port to give was sufficient to prevent creating a
ServiceAnnouncer with an empty ID,
but we can be more defensive about this and check for a null pointer.
  • Loading branch information
fishface60 committed Dec 27, 2024
1 parent 673b1a6 commit 39bdbfa
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/main/java/net/rptools/maptool/client/MapTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public class MapTool {
var campaign = CampaignFactory.createBasicCampaign();
var policy = new ServerPolicy();

server = new MapToolServer("", new Campaign(campaign), null, false, policy, playerDB);
server = new MapToolServer(null, new Campaign(campaign), null, false, policy, playerDB);
client = new MapToolClient(server, campaign, playerDB.getPlayer(), connections.clientSide());
} catch (NoSuchAlgorithmException | InvalidKeySpecException e) {
throw new RuntimeException("Unable to create default personal server", e);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/net/rptools/maptool/server/MapToolServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public enum State {
private State currentState;

public MapToolServer(
String id,
@Nullable String id,
Campaign campaign,
@Nullable ServerConfig config,
boolean useUPnP,
Expand All @@ -103,7 +103,7 @@ public MapToolServer(
this.playerDatabase = playerDb;

this.announcer =
config == null
config == null || id == null
? null
: new ServiceAnnouncer(id, config.getPort(), AppConstants.SERVICE_GROUP);

Expand Down

0 comments on commit 39bdbfa

Please sign in to comment.