Skip to content

Commit a48c398

Browse files
Merge branch 'lightbend:main' into formatting-optins
2 parents 0e73fd7 + e1519d7 commit a48c398

File tree

14 files changed

+119
-133
lines changed

14 files changed

+119
-133
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ name: CI
22
on:
33
pull_request:
44
push:
5+
permissions:
6+
contents: read
57
jobs:
68
test:
79
runs-on: ubuntu-latest
@@ -14,12 +16,14 @@ jobs:
1416
- java: 11
1517
steps:
1618
- name: Checkout
17-
uses: actions/checkout@v2
19+
uses: actions/checkout@v4
1820
- name: Setup JDK
19-
uses: actions/setup-java@v2
21+
uses: actions/setup-java@v4
2022
with:
2123
distribution: temurin
2224
java-version: ${{ matrix.java }}
25+
- name: Setup sbt launcher
26+
uses: sbt/setup-sbt@v1
2327
- name: Build and test
2428
shell: bash
2529
run: sbt -v test doc

.github/workflows/release.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Release
2+
on:
3+
push:
4+
tags: ["v*"]
5+
jobs:
6+
test:
7+
runs-on: ubuntu-latest
8+
if: github.repository == 'lightbend/config'
9+
steps:
10+
- name: Checkout
11+
uses: actions/checkout@v2
12+
- name: Setup JDK
13+
uses: actions/setup-java@v2
14+
with:
15+
distribution: temurin
16+
java-version: 11
17+
- name: Setup SBT
18+
run: |
19+
# Make sure ca-certificates and gnupg are installed (often required for adding new repos)
20+
sudo apt-get update
21+
sudo apt-get install -y ca-certificates gnupg
22+
23+
# Add the sbt repositories to apt sources
24+
echo "deb https://repo.scala-sbt.org/scalasbt/debian all main" | sudo tee /etc/apt/sources.list.d/sbt.list
25+
echo "deb https://repo.scala-sbt.org/scalasbt/debian /" | sudo tee /etc/apt/sources.list.d/sbt_old.list
26+
27+
# Import the Scala SBT public key
28+
curl -sL "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x2EE0EA64E40A89B84B2DF73499E82A75642AC823" \
29+
| sudo apt-key add -
30+
31+
# Now update and install
32+
sudo apt-get update
33+
sudo apt-get install -y sbt
34+
- env:
35+
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
36+
PGP_SECRET: ${{ secrets.PGP_SECRET }}
37+
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
38+
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
39+
run: sbt ci-release

NEWS.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# 1.4.4: July 3, 2025
2+
3+
- build: bump actions to get sbt ([#818](https://github.com/lightbend/config/pull/818)) thanks to [@johanandren]((https://github.com/johanandren))
4+
- build: second try for sbt back in CI job ([#820](https://github.com/lightbend/config/pull/820)) thanks to [@johanandren]((https://github.com/johanandren))
5+
- fix: Incorrect abs of hashes in BadMap ([#817](https://github.com/lightbend/config/pull/817)) thanks to [@johanandren]((https://github.com/johanandren))
6+
17
# 1.4.3: October 17, 2023
28

39
- Optionally hide rendered environment variables ([#798](/../../pull/798))

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,12 @@ You can find published releases on Maven Central.
101101
<dependency>
102102
<groupId>com.typesafe</groupId>
103103
<artifactId>config</artifactId>
104-
<version>1.4.3</version>
104+
<version>1.4.4</version>
105105
</dependency>
106106

107107
sbt dependency:
108108

109-
libraryDependencies += "com.typesafe" % "config" % "1.4.3"
109+
libraryDependencies += "com.typesafe" % "config" % "1.4.4"
110110

111111
Link for direct download if you don't use a dependency manager:
112112

@@ -921,7 +921,8 @@ format.
921921

922922
#### Rust port
923923

924-
* https://github.com/mockersf/hocon.rs
924+
* https://github.com/mockersf/hocon.rs (unmaintained)
925+
* https://github.com/mikai233/hocon-rs
925926

926927
#### Go port
927928

@@ -936,7 +937,7 @@ format.
936937

937938
#### Online playground
938939

939-
* https://hocon-playground.avelier.dev/
940+
* https://hocon-playground.tehbrian.dev
940941

941942
# Maintenance notes
942943

build.sbt

Lines changed: 23 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
// to release, bump major/minor/micro as appropriate,
2-
// update NEWS, update version in README.md, tag, then
3-
// publishSigned.
4-
// Release tags should follow: http://semver.org/
5-
import scalariform.formatter.preferences._
6-
71
ThisBuild / git.baseVersion := "1.4.0"
82
ThisBuild / organization := "com.typesafe"
93
ThisBuild / Compile / scalacOptions := List("-unchecked", "-deprecation", "-feature")
@@ -25,11 +19,6 @@ ThisBuild / description := "configuration library for JVM languages
2519
ThisBuild / licenses := List("Apache-2.0" -> url("https://www.apache.org/licenses/LICENSE-2.0"))
2620
ThisBuild / homepage := Option(url("https://github.com/lightbend/config"))
2721
ThisBuild / pomIncludeRepository := { _ => false }
28-
ThisBuild / publishTo := {
29-
val nexus = "https://oss.sonatype.org/"
30-
if ((ThisBuild / isSnapshot).value) Option("Sonatype OSS Snapshots" at nexus + "content/repositories/snapshots")
31-
else Option("Sonatype OSS Staging" at nexus + "service/local/staging/deploy/maven2")
32-
}
3322
ThisBuild / publishMavenStyle := true
3423

3524
lazy val root = (project in file("."))
@@ -40,49 +29,39 @@ lazy val root = (project in file("."))
4029
simpleLibJava, simpleAppJava, complexAppJava
4130
)
4231
.settings(commonSettings)
43-
.settings(nocomma {
44-
name := "config-root"
45-
git.baseVersion := (ThisBuild / git.baseVersion).value
46-
doc / aggregate := false
47-
doc := (configLib / Compile / doc).value
48-
packageDoc / aggregate := false
32+
.settings(
33+
name := "config-root",
34+
git.baseVersion := (ThisBuild / git.baseVersion).value,
35+
doc / aggregate := false,
36+
doc := (configLib / Compile / doc).value,
37+
packageDoc / aggregate := false,
4938
packageDoc := (configLib / Compile / packageDoc).value
50-
checkstyle / aggregate := false
51-
checkstyle := (configLib / Compile / checkstyle).value
52-
useGpg := true
53-
PgpKeys.publishSigned / aggregate := false
54-
PgpKeys.publishSigned := (PgpKeys.publishSigned in configLib).value
55-
PgpKeys.publishLocalSigned / aggregate := false
56-
PgpKeys.publishLocalSigned := (PgpKeys.publishLocalSigned in configLib).value
57-
})
39+
)
5840

5941
lazy val configLib = Project("config", file("config"))
6042
.enablePlugins(SbtOsgi)
6143
.dependsOn(testLib % "test->test")
6244
.settings(osgiSettings)
63-
.settings(nocomma {
64-
autoScalaLibrary := false
65-
crossPaths := false
66-
libraryDependencies += "net.liftweb" %% "lift-json" % "3.3.0" % Test
67-
libraryDependencies += "com.novocode" % "junit-interface" % "0.11" % Test
45+
.settings(
46+
autoScalaLibrary := false,
47+
crossPaths := false,
48+
libraryDependencies += "net.liftweb" %% "lift-json" % "3.3.0" % Test,
49+
libraryDependencies += "com.novocode" % "junit-interface" % "0.11" % Test,
6850

6951
Compile / compile / javacOptions ++= Seq("-source", "1.8", "-target", "1.8",
70-
"-g", "-Xlint:unchecked")
52+
"-g", "-Xlint:unchecked"),
7153

7254
Compile / doc / javacOptions ++= Seq("-group", s"Public API (version ${version.value})", "com.typesafe.config:com.typesafe.config.parser",
73-
"-group", "Internal Implementation - Not ABI Stable", "com.typesafe.config.impl")
74-
javadocSourceBaseUrl := {
75-
for (gitHead <- com.typesafe.sbt.SbtGit.GitKeys.gitHeadCommit.value)
76-
yield s"https://github.com/lightbend/config/blob/$gitHead/config/src/main/java"
77-
}
55+
"-group", "Internal Implementation - Not ABI Stable", "com.typesafe.config.impl"),
56+
javadocSourceBaseUrl := Some("https://github.com/lightbend/config/tree/main/config/src/main/java"),
7857
// because we test some global state such as singleton caches,
7958
// we have to run tests in serial.
80-
Test / parallelExecution := false
59+
Test / parallelExecution := false,
8160

82-
test / fork := true
83-
Test / fork := true
84-
run / fork := true
85-
Test/ run / fork := true
61+
test / fork := true,
62+
Test / fork := true,
63+
run / fork := true,
64+
Test/ run / fork := true,
8665

8766
//env vars for tests
8867
Test / envVars ++= Map("testList.0" -> "0",
@@ -99,63 +78,15 @@ lazy val configLib = Project("config", file("config"))
9978
"SECRET_A" -> "A", // ConfigTest.renderShowEnvVariableValues
10079
"SECRET_B" -> "B", // ConfigTest.renderShowEnvVariableValues
10180
"SECRET_C" -> "C" // ConfigTest.renderShowEnvVariableValues
102-
)
81+
),
10382

104-
OsgiKeys.exportPackage := Seq("com.typesafe.config", "com.typesafe.config.impl")
105-
publish := sys.error("use publishSigned instead of plain publish")
106-
publishLocal := sys.error("use publishLocalSigned instead of plain publishLocal")
83+
OsgiKeys.exportPackage := Seq("com.typesafe.config", "com.typesafe.config.impl"),
10784
Compile / packageBin / packageOptions +=
10885
Package.ManifestAttributes("Automatic-Module-Name" -> "typesafe.config" )
109-
scalariformPreferences := scalariformPreferences.value
110-
.setPreference(IndentSpaces, 4)
111-
.setPreference(FirstArgumentOnNewline, Preserve)
112-
113-
checkstyleConfigLocation := CheckstyleConfigLocation.File((baseDirectory.value / "checkstyle-config.xml").toString)
114-
115-
Compile / checkstyle := {
116-
val log = streams.value.log
117-
(Compile / checkstyle).value
118-
val resultFile = (Compile / checkstyleOutputFile).value
119-
val results = scala.xml.XML.loadFile(resultFile)
120-
val errorFiles = results \\ "checkstyle" \\ "file"
121-
122-
def errorFromXml(node: scala.xml.NodeSeq): (String, String, String) = {
123-
val line: String = (node \ "@line" text)
124-
val msg: String = (node \ "@message" text)
125-
val source: String = (node \ "@source" text)
126-
(line, msg, source)
127-
}
128-
def errorsFromXml(fileNode: scala.xml.NodeSeq): Seq[(String, String, String, String)] = {
129-
val name: String = (fileNode \ "@name" text)
130-
val errors = (fileNode \\ "error") map { e => errorFromXml(e) }
131-
errors map { case (line, error, source) => (name, line, error, source) }
132-
}
133-
134-
val errors = errorFiles flatMap { f => errorsFromXml(f) }
135-
136-
if (errors.nonEmpty) {
137-
for (e <- errors) {
138-
log.error(s"${e._1}:${e._2}: ${e._3} (from ${e._4})")
139-
}
140-
throw new RuntimeException(s"Checkstyle failed with ${errors.size} errors")
141-
}
142-
log.info("No errors from checkstyle")
143-
}
144-
145-
// add checkstyle as a dependency of doc
146-
Compile / doc := ((Compile / doc).dependsOn(Compile / checkstyle)).value
147-
148-
findbugsReportType := Some(FindbugsReport.Html)
149-
findbugsReportPath := Some(crossTarget.value / "findbugs.html")
150-
findbugsEffort := FindbugsEffort.Maximum
151-
findbugsMaxMemory := 2000
152-
})
86+
)
15387

15488
lazy val commonSettings: Seq[Setting[_]] = Def.settings(
15589
unpublished,
156-
scalariformPreferences := scalariformPreferences.value
157-
.setPreference(IndentSpaces, 4)
158-
.setPreference(FirstArgumentOnNewline, Preserve),
15990
Compile / compile / javacOptions ++= Seq("-source", "1.8", "-target", "1.8"),
16091
)
16192

config/src/main/java/com/typesafe/config/Config.java

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -669,8 +669,7 @@ public interface Config extends ConfigMergeable {
669669
* Gets a value as a size in bytes (parses special strings like "128M"). If
670670
* the value is already a number, then it's left alone; if it's a string,
671671
* it's parsed understanding unit suffixes such as "128K", as documented in
672-
* the <a
673-
* href="https://github.com/lightbend/config/blob/main/HOCON.md">the
672+
* <a href="https://github.com/lightbend/config/blob/main/HOCON.md">the
674673
* spec</a>.
675674
*
676675
* @param path
@@ -689,8 +688,7 @@ public interface Config extends ConfigMergeable {
689688
* Gets a value as an amount of memory (parses special strings like "128M"). If
690689
* the value is already a number, then it's left alone; if it's a string,
691690
* it's parsed understanding unit suffixes such as "128K", as documented in
692-
* the <a
693-
* href="https://github.com/lightbend/config/blob/main/HOCON.md">the
691+
* <a href="https://github.com/lightbend/config/blob/main/HOCON.md">the
694692
* spec</a>.
695693
*
696694
* @since 1.3.0
@@ -710,9 +708,8 @@ public interface Config extends ConfigMergeable {
710708
/**
711709
* Get value as a duration in milliseconds. If the value is already a
712710
* number, then it's left alone; if it's a string, it's parsed understanding
713-
* units suffixes like "10m" or "5ns" as documented in the <a
714-
* href="https://github.com/lightbend/config/blob/main/HOCON.md">the
715-
* spec</a>.
711+
* units suffixes like "10m" or "5ns" as documented in
712+
* <a href="https://github.com/lightbend/config/blob/main/HOCON.md">the spec</a>.
716713
*
717714
* @deprecated As of release 1.1, replaced by {@link #getDuration(String, TimeUnit)}
718715
*
@@ -753,9 +750,8 @@ public interface Config extends ConfigMergeable {
753750
* {@link java.util.concurrent.TimeUnit TimeUnit}. If the value is already a
754751
* number, then it's taken as milliseconds and then converted to the
755752
* requested TimeUnit; if it's a string, it's parsed understanding units
756-
* suffixes like "10m" or "5ns" as documented in the <a
757-
* href="https://github.com/lightbend/config/blob/main/HOCON.md">the
758-
* spec</a>.
753+
* suffixes like "10m" or "5ns" as documented in
754+
* <a href="https://github.com/lightbend/config/blob/main/HOCON.md">the spec</a>.
759755
*
760756
* @since 1.2.0
761757
*
@@ -777,9 +773,9 @@ public interface Config extends ConfigMergeable {
777773
* Gets a value as a java.time.Duration. If the value is
778774
* already a number, then it's taken as milliseconds; if it's
779775
* a string, it's parsed understanding units suffixes like
780-
* "10m" or "5ns" as documented in the <a
781-
* href="https://github.com/lightbend/config/blob/main/HOCON.md">the
782-
* spec</a>. This method never returns null.
776+
* "10m" or "5ns" as documented in
777+
* <a href="https://github.com/lightbend/config/blob/main/HOCON.md">the spec</a>.
778+
* This method never returns null.
783779
*
784780
* @since 1.3.0
785781
*
@@ -799,9 +795,9 @@ public interface Config extends ConfigMergeable {
799795
* Gets a value as a java.time.Period. If the value is
800796
* already a number, then it's taken as days; if it's
801797
* a string, it's parsed understanding units suffixes like
802-
* "10d" or "5w" as documented in the <a
803-
* href="https://github.com/lightbend/config/blob/main/HOCON.md">the
804-
* spec</a>. This method never returns null.
798+
* "10d" or "5w" as documented in
799+
* <a href="https://github.com/lightbend/config/blob/main/HOCON.md">the spec</a>.
800+
* This method never returns null.
805801
*
806802
* @since 1.3.0
807803
*
@@ -819,7 +815,7 @@ public interface Config extends ConfigMergeable {
819815

820816
/**
821817
* Gets a value as a java.time.temporal.TemporalAmount.
822-
* This method will first try get get the value as a java.time.Duration, and if unsuccessful,
818+
* This method will first try to get the value as a java.time.Duration, and if unsuccessful,
823819
* then as a java.time.Period.
824820
* This means that values like "5m" will be parsed as 5 minutes rather than 5 months
825821
* @param path path expression

config/src/main/java/com/typesafe/config/ConfigFactory.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -618,9 +618,10 @@ public static Config systemProperties() {
618618
* <p>
619619
* Environment variables are mangled in the following way after stripping the prefix "CONFIG_FORCE_":
620620
* <table border="1">
621+
* <caption>environment variables</caption>
621622
* <tr>
622-
* <th bgcolor="silver">Env Var</th>
623-
* <th bgcolor="silver">Config</th>
623+
* <th>Env Var</th>
624+
* <th>Config</th>
624625
* </tr>
625626
* <tr>
626627
* <td>_&nbsp;&nbsp;&nbsp;[1 underscore]</td>

config/src/main/java/com/typesafe/config/impl/BadMap.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,13 @@ BadMap<K,V> copyingPut(K k, V v) {
6868
}
6969

7070
private static <K,V> void store(Entry[] entries, int hash, K k, V v) {
71-
int i = hash % entries.length;
71+
int i = Math.abs(hash % entries.length);
7272
Entry old = entries[i]; // old may be null
7373
entries[i] = new Entry(hash, k, v, old);
7474
}
7575

7676
private static void store(Entry[] entries, Entry e) {
77-
int i = e.hash % entries.length;
77+
int i = Math.abs(e.hash % entries.length);
7878
Entry old = entries[i]; // old may be null
7979
if (old == null && e.next == null) {
8080
// share the entry since it has no "next"
@@ -100,8 +100,8 @@ V get(K k) {
100100
if (entries.length == 0) {
101101
return null;
102102
} else {
103-
int hash = Math.abs(k.hashCode());
104-
int i = hash % entries.length;
103+
int hash = k.hashCode();
104+
int i = Math.abs(hash % entries.length);
105105
Entry e = entries[i];
106106
if (e == null)
107107
return null;

config/src/main/java/com/typesafe/config/impl/package.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
-->
77

88
</head>
9-
<body bgcolor="white">
9+
<body>
1010

1111
<p>
1212
Internal implementation details that can change ABI at any time.

0 commit comments

Comments
 (0)