Skip to content

Commit 0d59de9

Browse files
committed
fix provider type name
1 parent 9bc473a commit 0d59de9

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ ThisBuild / organization := "app.softnetwork"
22

33
name := "resource"
44

5-
ThisBuild / version := "0.8.3"
5+
ThisBuild / version := "0.8.4"
66

77
ThisBuild / scalaVersion := "2.12.18"
88

common/src/main/scala/app/softnetwork/resource/spi/ResourceProviders.scala

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,25 @@ object ResourceProviders {
1717
}
1818

1919
def provider(providerType: ProviderType): ResourceProvider = {
20-
resourceProviders.get(providerType.name) match {
20+
val name = providerType.name.toLowerCase
21+
resourceProviders.get(name) match {
2122
case Some(provider) => provider
2223
case None =>
23-
resourceProviderFactories
24-
.iterator()
25-
.asScala
26-
.find(_.providerType == providerType)
24+
val factories = resourceProviderFactories.iterator().asScala
25+
factories
26+
.find(_.providerType.name.toLowerCase == name)
2727
.map { factory =>
2828
val provider = factory.provider
29-
registerProvider(providerType.name, provider)
29+
registerProvider(name, provider)
3030
provider
3131
}
32-
.getOrElse(throw new Exception(s"No provider found for type ${providerType.name}"))
32+
.getOrElse {
33+
val providerTypeNames = factories.map(_.providerType.name.toLowerCase).toList
34+
throw new Exception(
35+
s"No provider found for type $name within available providers: [${providerTypeNames
36+
.mkString(",")}]"
37+
)
38+
}
3339
}
3440
}
3541
}

0 commit comments

Comments
 (0)