Skip to content

Commit

Permalink
fixes for final release of Solr 1.6.0
Browse files Browse the repository at this point in the history
release 1.6.1-RC-1
  • Loading branch information
apatrida committed Apr 24, 2016
1 parent f1d5252 commit 99f986e
Show file tree
Hide file tree
Showing 6 changed files with 149 additions and 30 deletions.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
group=uy.kohesive.solr
version=1.6.0
version=1.6.1-RC-1

systemProp.file.encoding=UTF-8

version_kotlin=1.0.0

version_undertow=1.3.18.Final
version_solr=5.5.0
version_solr=6.0.0

version_klutter=1.15.1
version_typesafe_config=1.2.1
Expand Down
120 changes: 120 additions & 0 deletions src/main/kotlin/uy/kohesive/solr/undertow/CustomClassloader.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
package uy.kohesive.solr.undertow

import java.io.InputStream
import java.net.URL
import java.net.URLClassLoader
import java.util.*


/**
* A parent-last classloader that will try the child classloader first and then the parent.
*/
class ChildFirstClassloader(classpath: List<URL>, parentClassLoader: ClassLoader?) : ClassLoader(parentClassLoader) {
private val childClassLoader = ChildURLClassLoader(classpath.toTypedArray(), parent)

@Synchronized
override fun loadClass(name: String, resolve: Boolean): Class<*> {
try {
// first we try to find a class inside the child classloader
return childClassLoader.findClass(name)
} catch (e: ClassNotFoundException) {
// didn't find it, try the parent
return super.loadClass(name, resolve)
}
}

override fun loadClass(name: String): Class<*> {
return loadClass(name, false)
}

override fun findClass(name: String): Class<*> {
try {
return childClassLoader.findClass(name)
} catch (e: ClassNotFoundException) {
/* nop */
}
return super.findClass(name)
}


/**
* This class delegates (child then parent) for the findClass method for a URLClassLoader.
* We need this because findClass is protected in URLClassLoader
*/
private class ChildURLClassLoader(urls: Array<URL>, private val realParent: ClassLoader) : URLClassLoader(urls, null) {
public override fun findClass(name: String): Class<*> {
val loaded = super.findLoadedClass(name)
if (loaded != null)
return loaded

try {
// first try to use the URLClassLoader findClass
return super.findClass(name)
} catch (e: ClassNotFoundException) {
// if that fails, we ask our real parent classloader to load the class (we give up)
return realParent.loadClass(name)
}
}
}

override fun findResource(name: String): URL? {
return childClassLoader.findResource(name) ?: super.findResource(name)
}

override fun getResource(name: String): URL? {
return childClassLoader.getResource(name) ?: super.getResource(name)
}

class UrlEnumeration(val iter: Iterator<URL>): Enumeration<URL> {
override fun nextElement(): URL {
return iter.next()
}

override fun hasMoreElements(): Boolean {
return iter.hasNext()
}

}

override fun findResources(name: String): Enumeration<URL> {
val combined = childClassLoader.findResources(name).asSequence() + super.findResources(name).asSequence()
return UrlEnumeration(combined.iterator())
}

override fun getResources(name: String): Enumeration<URL> {
val combined = childClassLoader.getResources(name).asSequence() + super.getResources(name).asSequence()
return UrlEnumeration(combined.iterator())
}

override fun getResourceAsStream(name: String): InputStream? {
return childClassLoader.getResourceAsStream(name) ?: super.getResourceAsStream(name)
}

override fun setClassAssertionStatus(className: String?, enabled: Boolean) {
childClassLoader.setClassAssertionStatus(className, enabled)
super.setClassAssertionStatus(className, enabled)
}

override fun clearAssertionStatus() {
childClassLoader.clearAssertionStatus()
super.clearAssertionStatus()
}

override fun setDefaultAssertionStatus(enabled: Boolean) {
childClassLoader.setDefaultAssertionStatus(enabled)
super.setDefaultAssertionStatus(enabled)
}

override fun setPackageAssertionStatus(packageName: String, enabled: Boolean) {
childClassLoader.setPackageAssertionStatus(packageName, enabled)
super.setPackageAssertionStatus(packageName, enabled)
}


// TODO: should these be overriden?
// override fun getPackages(): Array<out Package>? { }
// override fun getPackage(name: String?): Package? { }
// override fun definePackage(name: String?, specTitle: String?, specVersion: String?, specVendor: String?, implTitle: String?, implVersion: String?, implVendor: String?, sealBase: URL?): Package? { }
// override fun addClass(c: Class<*>?) { }
// override fun getClassLoadingLock(className: String?): Any? { }
}
24 changes: 19 additions & 5 deletions src/main/kotlin/uy/kohesive/solr/undertow/SolrUndertow.kt
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,16 @@ class Server(cfgLoader: ServerConfigLoader) {
}

private fun buildSolrServletHandler(solrWarDeployment: DeployedDistributionInfo): ServletDeploymentAndHandler {
val solrVersion = cfg.solrVersion
val isSolr6 = solrVersion.substringBefore('.').toInt() == 6
val welcomePages = listOf("index.html", "old.html") +
if (isSolr6) {
emptyList()
}
else {
listOf("admin.html")
}

// load all by name so we have no direct dependency on Solr
val solrDispatchFilterClass = solrWarDeployment.classLoader.loadClass("org.apache.solr.servlet.SolrDispatchFilter").asSubclass(Filter::class.java)
val solrZookeeprServletClass = try {
Expand All @@ -359,6 +369,7 @@ class Server(cfgLoader: ServerConfigLoader) {
}



// mimic solr web.xml file, minus old deprecated redirects from old UI...
val deployment = Servlets.deployment()
.setClassLoader(solrWarDeployment.classLoader)
Expand All @@ -375,17 +386,19 @@ class Server(cfgLoader: ServerConfigLoader) {
.addFilterUrlMapping("SolrRequestFilter", "/*", DispatcherType.REQUEST)
.addServlets(
Servlets.servlet("LoadAdminUI", solrAdminUiServletClass)
.addMapping("index.html")
.addMapping("admin.html")
.addMapping("old.html")
.apply {
welcomePages.forEach {
addMapping(it)
}
}
.setRequireWelcomeFileMapping(true),
Servlets.servlet("SolrRestApi", solrRestApiServletClass)
.addInitParam("org.restlet.application", solrRestApiClass.getName())
.addMapping("/schema/*")
.setRequireWelcomeFileMapping(true)
)
.addMimeMapping(MimeMapping(".xsl", "application/xslt+xml"))
.addWelcomePages("index.html", "admin.html")
.addWelcomePages(welcomePages)
solrWarDeployment.htmlDir?.let { htmlDir ->
deployment.setResourceManager(FileResourceManager(solrWarDeployment.htmlDir.toFile(), 1024))
}
Expand Down Expand Up @@ -424,7 +437,8 @@ class Server(cfgLoader: ServerConfigLoader) {
val pathHandler = Handlers.path(Handlers.redirect(cfg.solrContextPath.mustEndWith('/')+"index.html"))
.addPrefixPath(cfg.solrContextPath, wrappedHandlers)

val oldAdminUiFixer = Handlers.path(pathHandler).addExactPath(cfg.solrContextPath, Handlers.redirect(cfg.solrContextPath.mustEndWith('/')+"admin.html"))
val redirectToAdmin = if (isSolr6) "index.html" else "admin.html"
val oldAdminUiFixer = Handlers.path(pathHandler).addExactPath(cfg.solrContextPath, Handlers.redirect(cfg.solrContextPath.mustEndWith('/')+redirectToAdmin))

return ServletDeploymentAndHandler(servletDeploymentMgr, oldAdminUiFixer)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,13 @@ import kotlin.test.fail
class TestServerWithPlugin {
companion object {
val workingDir = Paths.get("test-data/solr-standalone").toAbsolutePath()
val coreWithPluginDir = workingDir.resolve("plugin-test/collection1")
val solrVersion = SolrCore::class.java.`package`.specificationVersion
val coreWithPluginDir = if (solrVersion.substringBefore('.').toInt() >= 6) {
workingDir.resolve("plugin-test/collection-solr6")
} else {
workingDir.resolve("plugin-test/collection1")
}


lateinit var server: Server

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -720,21 +720,7 @@
<!-- A specialized field for geospatial search. If indexed, this fieldType must not be multivalued. -->
<fieldType name="location" class="solr.LatLonType" subFieldSuffix="_coordinate"/>

<!-- An alternative geospatial field type new to Solr 4. It supports multiValued and polygon shapes.
For more information about this and other Spatial fields new to Solr 4, see:
http://wiki.apache.org/solr/SolrAdaptersForLuceneSpatial4
-->
<fieldType name="location_rpt" class="solr.SpatialRecursivePrefixTreeFieldType"
geo="true" distErrPct="0.025" maxDistErr="0.000009" units="degrees" />

<!-- Spatial rectangle (bounding box) field. It supports most spatial predicates, and has
special relevancy modes: score=overlapRatio|area|area2D (local-param to the query). DocValues is required for
relevancy. -->
<fieldType name="bbox" class="solr.BBoxField"
geo="true" units="degrees" numberType="_bbox_coord" />
<fieldType name="_bbox_coord" class="solr.TrieDoubleField" precisionStep="8" docValues="true" stored="false"/>

<!-- Money/currency field type. See http://wiki.apache.org/solr/MoneyFieldType
<!-- Money/currency field type. See http://wiki.apache.org/solr/MoneyFieldType
Parameters:
defaultCurrency: Specifies the default currency if none specified. Defaults to "USD"
precisionStep: Specifies the precisionStep for the TrieLong field used for the amount
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,13 +328,6 @@
this is enabled here, and controlled through log4j.properties.
-->
<infoStream>true</infoStream>

<!--
Use true to enable this safety check, which can help
reduce the risk of propagating index corruption from older segments
into new ones, at the expense of slower merging.
-->
<checkIntegrityAtMerge>false</checkIntegrityAtMerge>
</indexConfig>


Expand Down

0 comments on commit 99f986e

Please sign in to comment.