Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into feature/jsr-310-lo…
Browse files Browse the repository at this point in the history
…caldate

# Conflicts:
#	src/main/java/net/fortuna/ical4j/model/Recur.java
#	src/main/java/net/fortuna/ical4j/model/TimeZoneLoader.java
  • Loading branch information
benfortuna committed Apr 14, 2022
2 parents dd23f46 + 8dda544 commit e620bf3
Show file tree
Hide file tree
Showing 12 changed files with 194 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .env
@@ -1,4 +1,4 @@
CHANGELOG_START_TAG=ical4j-3.2.0
CHANGELOG_START_TAG=ical4j-3.2.1
CHANGELOG_END_TAG=HEAD

GRADLE_VERSION=6.9.1
1 change: 1 addition & 0 deletions .github/FUNDING.yml
@@ -0,0 +1 @@
github: benfortuna
70 changes: 70 additions & 0 deletions .github/workflows/codeql-analysis.yml
@@ -0,0 +1,70 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches: [ develop, master ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ develop ]
schedule:
- cron: '20 13 * * 6'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'java' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://git.io/codeql-language-support

steps:
- name: Checkout repository
uses: actions/checkout@v3

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
2 changes: 2 additions & 0 deletions .github/workflows/publish-snapshots.yml
Expand Up @@ -6,6 +6,8 @@ on:
- 'develop'
- 'feature/jsr-310-localdate'

permissions: read-all

jobs:
gradle:
runs-on: ubuntu-latest
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/run-build.yml
Expand Up @@ -5,6 +5,8 @@ name: Java CI with Gradle

on: [push]

permissions: read-all

jobs:
build:

Expand Down
55 changes: 55 additions & 0 deletions .github/workflows/scorecards.yml
@@ -0,0 +1,55 @@
name: Scorecards supply-chain security
on:
# Only the default branch is supported.
branch_protection_rule:
schedule:
- cron: '36 1 * * 3'
push:
branches: [ develop ]

# Declare default permissions as read only.
permissions: read-all

jobs:
analysis:
name: Scorecards analysis
runs-on: ubuntu-latest
permissions:
# Needed to upload the results to code-scanning dashboard.
security-events: write
actions: read
contents: read

steps:
- name: "Checkout code"
uses: actions/checkout@a12a3943b4bdde767164f792f33f40b04645d846 # v3.0.0
with:
persist-credentials: false

- name: "Run analysis"
uses: ossf/scorecard-action@c1aec4ac820532bab364f02a81873c555a0ba3a1 # v1.0.4
with:
results_file: results.sarif
results_format: sarif
# Read-only PAT token. To create it,
# follow the steps in https://github.com/ossf/scorecard-action#pat-token-creation.
repo_token: ${{ secrets.SCORECARD_READ_TOKEN }}
# Publish the results to enable scorecard badges. For more details, see
# https://github.com/ossf/scorecard-action#publishing-results.
# For private repositories, `publish_results` will automatically be set to `false`,
# regardless of the value entered here.
publish_results: true

# Upload the results as artifacts (optional).
- name: "Upload artifact"
uses: actions/upload-artifact@6673cd052c4cd6fcf4b4e6e60ea986c889389535 # v3.0.0
with:
name: SARIF file
path: results.sarif
retention-days: 5

# Upload the results to GitHub's code scanning dashboard.
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@5f532563584d71fdef14ee64d17bafb34f751ce5 # v1.0.26
with:
sarif_file: results.sarif
2 changes: 1 addition & 1 deletion gradle.properties
Expand Up @@ -22,4 +22,4 @@ sonatype_password=
org.gradle.caching = true
org.gradle.vfs.watch = true

revApiOldVersion = 3.2.0
revApiOldVersion = 3.2.1
42 changes: 42 additions & 0 deletions src/main/java/net/fortuna/ical4j/model/Recur.java
Expand Up @@ -1083,6 +1083,26 @@ private void readObject(final java.io.ObjectInputStream stream) throws IOExcepti
log = LoggerFactory.getLogger(Recur.class);
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Recur recur = (Recur) o;
return frequency == recur.frequency && skip == recur.skip && Objects.equals(until, recur.until) &&
rscale == recur.rscale && Objects.equals(count, recur.count) && Objects.equals(interval, recur.interval) &&
Objects.equals(secondList, recur.secondList) && Objects.equals(minuteList, recur.minuteList) &&
Objects.equals(hourList, recur.hourList) && Objects.equals(dayList, recur.dayList) &&
Objects.equals(monthDayList, recur.monthDayList) && Objects.equals(yearDayList, recur.yearDayList) &&
Objects.equals(weekNoList, recur.weekNoList) && Objects.equals(monthList, recur.monthList) &&
Objects.equals(setPosList, recur.setPosList) && weekStartDay == recur.weekStartDay;
}

@Override
public int hashCode() {
return Objects.hash(frequency, skip, until, rscale, count, interval, secondList, minuteList, hourList, dayList,
monthDayList, yearDayList, weekNoList, monthList, setPosList, weekStartDay);
}

/**
* Support for building Recur instances.
*/
Expand Down Expand Up @@ -1120,6 +1140,28 @@ public static class Builder<T extends Temporal> {

private WeekDay weekStartDay;

public Builder() {
}

public Builder(Recur<T> recur) {
this.frequency = recur.frequency;
this.rscale = recur.rscale;
this.skip = recur.skip;
this.until = recur.until.getTemporal();
this.count = recur.count;
this.interval = recur.interval;
this.secondList = recur.secondList;
this.minuteList = recur.minuteList;
this.hourList = recur.hourList;
this.dayList = recur.dayList;
this.monthDayList = recur.monthDayList;
this.yearDayList = recur.yearDayList;
this.weekNoList = recur.weekNoList;
this.monthList = recur.monthList;
this.setPosList = recur.setPosList;
this.weekStartDay = recur.weekStartDay;
}

public Builder<T> frequency(Frequency frequency) {
this.frequency = frequency;
return this;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/fortuna/ical4j/model/TimeZoneLoader.java
Expand Up @@ -82,7 +82,7 @@ public VTimeZone loadVTimeZone(String id) throws IOException, ParserException {
final CalendarBuilder builder = new CalendarBuilder();
final Calendar calendar = builder.build(in);
final Optional<VTimeZone> vTimeZone = calendar.getComponent(Component.VTIMEZONE);
// load any available updates for the timezone.. can be explicility disabled via configuration
// load any available updates for the timezone.. can be explicitly disabled via configuration
vTimeZone.ifPresent(timeZone -> cache.putIfAbsent(id, zoneUpdater.updateDefinition(timeZone)));
}
} else {
Expand Down
18 changes: 14 additions & 4 deletions src/main/java/net/fortuna/ical4j/model/TimeZoneUpdater.java
Expand Up @@ -59,6 +59,7 @@ public class TimeZoneUpdater {
private static final String UPDATE_PROXY_TYPE = "net.fortuna.ical4j.timezone.update.proxy.type";
private static final String UPDATE_PROXY_HOST = "net.fortuna.ical4j.timezone.update.proxy.host";
private static final String UPDATE_PROXY_PORT = "net.fortuna.ical4j.timezone.update.proxy.port";
private static final String SECURE_CONNECTION_ENABLED = "net.fortuna.ical4j.timezone.update.connection.secure";

private Proxy proxy = null;

Expand Down Expand Up @@ -86,10 +87,19 @@ public URLConnection openConnection(URL url) throws IOException {
final int readTimeout = Configurator.getIntProperty(UPDATE_READ_TIMEOUT).orElse(0);

URLConnection connection;
if ("true".equals(Configurator.getProperty(UPDATE_PROXY_ENABLED).orElse("false")) && proxy != null) {
connection = url.openConnection(proxy);
if ("true".equals(Configurator.getProperty(SECURE_CONNECTION_ENABLED).orElse("false"))) {
URL secureUrl = new URL("https", url.getHost(), url.getFile());
if ("true".equals(Configurator.getProperty(UPDATE_PROXY_ENABLED).orElse("false")) && proxy != null) {
connection = secureUrl.openConnection(proxy);
} else {
connection = secureUrl.openConnection();
}
} else {
connection = url.openConnection();
if ("true".equals(Configurator.getProperty(UPDATE_PROXY_ENABLED).orElse("false")) && proxy != null) {
connection = url.openConnection(proxy);
} else {
connection = url.openConnection();
}
}

connection.setConnectTimeout(connectTimeout);
Expand All @@ -115,7 +125,7 @@ public VTimeZone updateDefinition(VTimeZone vTimeZone) {
return updatedVTimeZone.get();
}
} catch (IOException | ParserException e) {
LoggerFactory.getLogger(TimeZoneLoader.class).warn("Error updating timezone definition", e);
LoggerFactory.getLogger(TimeZoneUpdater.class).warn("Error updating timezone definition", e);
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/test/groovy/net/fortuna/ical4j/model/RecurSpec.groovy
Expand Up @@ -408,6 +408,9 @@ class RecurSpec extends Specification {

then: 'result is as expected'
recurDaily as String == "FREQ=DAILY;WKST=MO;UNTIL=20050307;INTERVAL=1;BYDAY=MO,TU,WE,TH,FR"

and: 'a new builder based on the recur generates the same definition'
new Recur.Builder(recurDaily).build() == recurDaily
}

def 'test Recur.getNextDate() with different recurrence rules'() {
Expand Down
3 changes: 2 additions & 1 deletion src/test/resources/ical4j.properties
Expand Up @@ -34,13 +34,14 @@

#net.fortuna.ical4j.timezone.registry=net.fortuna.ical4j.model.DefaultTimeZoneRegistryFactory

net.fortuna.ical4j.timezone.update.enabled=false
net.fortuna.ical4j.timezone.update.enabled=true
#net.fortuna.ical4j.timezone.update.timeout.connect ## - Connect timeout ( milliseconds, e.g. 10000 - 10s, unlimited by default )
#net.fortuna.ical4j.timezone.update.timeout.read ## - Read timeout ( milliseconds, e.g. 10000 - 10s, unlimited by default )
#net.fortuna.ical4j.timezone.update.proxy.enabled={true|false} ## - Use proxy ( true / false )
#net.fortuna.ical4j.timezone.update.proxy.type ## - Proxy type ( DIRECT / HTTP / SOCKS )
#net.fortuna.ical4j.timezone.update.proxy.host ## - Proxy server host name ( e.g. proxy.myorg.com )
#net.fortuna.ical4j.timezone.update.proxy.port=8080 ## - Proxy server port number ( e.g. 3128 )
net.fortuna.ical4j.timezone.update.connection.secure=true

#net.fortuna.ical4j.timezone.cache.impl=net.fortuna.ical4j.util.MapTimeZoneCache

Expand Down

0 comments on commit e620bf3

Please sign in to comment.