Skip to content

Commit

Permalink
Stop serialising licensed flag
Browse files Browse the repository at this point in the history
  • Loading branch information
pugnascotia committed Dec 7, 2020
1 parent 1d9d6db commit e6276e8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ public void testPluginWithVerbose() throws Exception {
"Elasticsearch Version: " + Version.CURRENT.toString(),
"Java Version: 1.8",
"Native Controller: false",
"Licensed: false",
"Extended Plugins: []",
" * Classname: org.fake"),
terminal.getOutput());
Expand All @@ -173,7 +172,6 @@ public void testPluginWithNativeController() throws Exception {
"Elasticsearch Version: " + Version.CURRENT.toString(),
"Java Version: 1.8",
"Native Controller: true",
"Licensed: false",
"Extended Plugins: []",
" * Classname: org.fake"),
terminal.getOutput());
Expand All @@ -195,7 +193,6 @@ public void testPluginWithVerboseMultiplePlugins() throws Exception {
"Elasticsearch Version: " + Version.CURRENT.toString(),
"Java Version: 1.8",
"Native Controller: false",
"Licensed: false",
"Extended Plugins: []",
" * Classname: org.fake",
"fake_plugin2",
Expand All @@ -206,7 +203,6 @@ public void testPluginWithVerboseMultiplePlugins() throws Exception {
"Elasticsearch Version: " + Version.CURRENT.toString(),
"Java Version: 1.8",
"Native Controller: false",
"Licensed: false",
"Extended Plugins: []",
" * Classname: org.fake2"),
terminal.getOutput());
Expand Down
33 changes: 6 additions & 27 deletions server/src/main/java/org/elasticsearch/plugins/PluginInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ public class PluginInfo implements Writeable, ToXContentObject {
public static final String ES_PLUGIN_PROPERTIES = "plugin-descriptor.properties";
public static final String ES_PLUGIN_POLICY = "plugin-security.policy";

private static final Version LICENSED_PLUGINS_SUPPORT = Version.V_6_8_14;

private final String name;
private final String description;
private final String version;
Expand Down Expand Up @@ -123,11 +125,8 @@ public PluginInfo(final StreamInput in) throws IOException {
*/
in.readBoolean();
}
if (isLicensedPluginsSupported(in.getVersion())) {
isLicensed = in.readBoolean();
} else {
isLicensed = false;
}
// We don't serialise `isLicensed` in 6.8
isLicensed = false;
}

@Override
Expand All @@ -153,31 +152,13 @@ public void writeTo(final StreamOutput out) throws IOException {
*/
out.writeBoolean(false);
}
if (isLicensedPluginsSupported(out.getVersion())) {
out.writeBoolean(isLicensed);
}
// We don't serialise `isLicensed` in 6.8
}

// We have to create our own Version objects for 7.x because they aren't defined in the Version class.
private static final Version V_7_0_0 = Version.fromId(7_00_00_99);
private static final Version V_7_11_0 = Version.fromId(7_11_00_99);

/**
* Checks whether licensed plugins are supported in the supplied version. Licensed plugins were
* introduced late in the 6.8 and 7.x lifecycle, so it is not possible to simply check whether
* the supplied version is higher than a specific version. Rather, the version could fall in
* one of two possible ranges.
* @param version the version to check
* @return whether licensed plugins are supported in the version
*/
private static boolean isLicensedPluginsSupported(Version version) {
if (version.onOrAfter(Version.V_6_8_14) && version.before(V_7_0_0)) {
return true;
}

return version.onOrAfter(V_7_11_0);
}

/**
* Reads the plugin descriptor file.
*
Expand Down Expand Up @@ -246,7 +227,7 @@ public static PluginInfo readFromProperties(final Path path) throws IOException
}

boolean isLicensed = false;
if (isLicensedPluginsSupported(esVersion)) {
if (esVersion.onOrAfter(LICENSED_PLUGINS_SUPPORT)) {
isLicensed = parseBooleanValue(name, "licensed", propsMap.remove("licensed"));
}

Expand Down Expand Up @@ -364,7 +345,6 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
builder.field("classname", classname);
builder.field("extended_plugins", extendedPlugins);
builder.field("has_native_controller", hasNativeController);
builder.field("licensed", isLicensed);
}
builder.endObject();

Expand Down Expand Up @@ -404,7 +384,6 @@ public String toString(String prefix) {
.append(prefix).append("Elasticsearch Version: ").append(elasticsearchVersion).append("\n")
.append(prefix).append("Java Version: ").append(javaVersion).append("\n")
.append(prefix).append("Native Controller: ").append(hasNativeController).append("\n")
.append(prefix).append("Licensed: ").append(isLicensed).append("\n")
.append(prefix).append("Extended Plugins: ").append(extendedPlugins).append("\n")
.append(prefix).append(" * Classname: ").append(classname);
return information.toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -502,8 +502,7 @@ public void testToXContent() throws IOException {
+ "\"description\":\"_plugin_desc\","
+ "\"classname\":\"_plugin_class\","
+ "\"extended_plugins\":[],"
+ "\"has_native_controller\":false,"
+ "\"licensed\":false"
+ "\"has_native_controller\":false"
+ "}"
+ "],"
+ "\"network_types\":{"
Expand Down

0 comments on commit e6276e8

Please sign in to comment.