-
Notifications
You must be signed in to change notification settings - Fork 674
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SOLR-16781: Disable <lib/> by default on 9.x (#2894)
`<lib/>` usage will now log a warning by default for future 9.x releases. Wary users can re-enabled the feature by specifying a sysprop: `solr.config.lib.enabled=true`. (This commit is for 9.x branches only, and not 'main')
- Loading branch information
1 parent
3b094fa
commit f492e24
Showing
11 changed files
with
142 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
solr/core/src/test/org/apache/solr/core/TestConfigWithLibDisabled.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.solr.core; | ||
|
||
import static org.apache.solr.core.SolrConfig.LIB_ENABLED_SYSPROP; | ||
import static org.hamcrest.core.StringContains.containsString; | ||
|
||
import java.io.IOException; | ||
import org.apache.solr.SolrTestCaseJ4; | ||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
|
||
// TODO - replace 'initCore' usage and merge with TestConfig | ||
/** | ||
* Unit test verifying that "lib" tags are quietly ignored when not explicitly enabled. | ||
* | ||
* <p>Based on code from {@link TestConfig}. | ||
*/ | ||
public class TestConfigWithLibDisabled extends SolrTestCaseJ4 { | ||
|
||
@BeforeClass | ||
public static void beforeClass() throws Exception { | ||
System.setProperty(LIB_ENABLED_SYSPROP, "false"); // <lib> tags disabled! | ||
initCore("solrconfig-test-misc.xml", "schema-reversed.xml"); | ||
} | ||
|
||
// solrconfig-test-misc has lib tags referencing various files | ||
// This test ensures that none of those files are loadable when | ||
// <lib> tags are disabled | ||
@Test | ||
public void testLibFilesShouldntBeVisible() throws IOException { | ||
SolrResourceLoader loader = h.getCore().getResourceLoader(); | ||
String[] filesReferencedByLib = | ||
new String[] { | ||
"empty-file-a1.txt", | ||
"empty-file-a2.txt", | ||
"empty-file-b1.txt", | ||
"empty-file-b2.txt", | ||
"empty-file-c1.txt" | ||
}; | ||
for (String f : filesReferencedByLib) { | ||
final var e = | ||
expectThrows( | ||
SolrResourceNotFoundException.class, | ||
() -> { | ||
loader.openResource(f); | ||
}); | ||
assertThat(e.getMessage(), containsString("Can't find resource")); | ||
assertThat(e.getMessage(), containsString(f)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters