Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ascii Art Loading Fix (All Connectors) #941

Merged
merged 2 commits into from
May 12, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ import org.apache.kafka.common.config.ConfigException
import org.apache.kafka.connect.source.SourceRecord
import org.apache.kafka.connect.source.SourceTask

import java.nio.charset.CodingErrorAction
import scala.io.Codec
import scala.io.Source
import scala.jdk.CollectionConverters.ListHasAsScala
import scala.jdk.CollectionConverters.MapHasAsScala
import scala.util.Failure
Expand All @@ -43,11 +46,7 @@ class MqttSourceTask extends SourceTask with StrictLogging {
private val manifest = JarManifest(getClass.getProtectionDomain.getCodeSource.getLocation)

override def start(props: util.Map[String, String]): Unit = {

logger.info(scala.io.Source.fromInputStream(
this.getClass.getResourceAsStream("/mqtt-source-ascii.txt"),
).mkString + s" $version")
logger.info(manifest.printManifest())
printAsciiHeader()

val conf = if (context.configs().isEmpty) props else context.configs()

Expand Down Expand Up @@ -90,6 +89,18 @@ class MqttSourceTask extends SourceTask with StrictLogging {
enableProgress = settings.enableProgress
}

private def printAsciiHeader(): Unit = {
implicit val codec: Codec = Codec("UTF-8")
codec.onMalformedInput(CodingErrorAction.REPLACE)
codec.onUnmappableCharacter(CodingErrorAction.REPLACE)
logger.info(
Source.fromInputStream(
getClass.getResourceAsStream("/mqtt-source-ascii.txt"),
).mkString + s" $version",
)
logger.info(manifest.printManifest())
}

/**
* Get all the messages accumulated so far.
*/
Expand Down